Skip to content

[fix][meta] Close resources when ZKMetadataStore construction fails - #26673

Merged
merlimat merged 1 commit into
apache:masterfrom
sakshichitnis27:issue/26582-zk-construction-cleanup
Sep 22, 2026
Merged

merlimat merged 1 commit into
apache:masterfrom
sakshichitnis27:issue/26582-zk-construction-cleanup

Conversation

@sakshichitnis27

@sakshichitnis27 sakshichitnis27 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #26582

Motivation

When ZKMetadataStore construction fails while connecting to ZooKeeper, superclass executors have already been created. Since the constructor never returns, the caller cannot close the store. The remaining non-daemon threads can prevent initialize-transaction-coordinator-metadata from exiting.

Modifications

  • Close superclass resources in the constructor failure path before rethrowing MetadataStoreException.
  • Preserve a cleanup failure as a suppressed exception on the original failure.
  • Add a regression test that verifies failed construction leaves no metadata-store threads alive.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Verified ZKMetadataStoreTest.constructorFailureClosesResources fails before the fix because the batch flusher remains alive and passes after the fix.
  • Ran the new regression test together with ZKSessionTest.
  • Ran ./gradlew --no-daemon --max-workers=1 quickCheck.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Failed ZKMetadataStore construction now shuts down the metadata-store executors that were created before the ZooKeeper connection attempt.

@merlimat
merlimat merged commit fe56cf3 into apache:master Sep 22, 2026
44 of 45 checks passed
@lhotari lhotari added this to the 5.0.0 milestone Oct 1, 2026
ascentstream-bot pushed a commit to ascentstream/pulsar that referenced this pull request Oct 1, 2026
ascentstream-bot pushed a commit to ascentstream/pulsar that referenced this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants