[fix][test] Fix flaky compaction disable test by controlling delete concurrency#25794
Open
void-ptr974 wants to merge 1 commit into
Open
[fix][test] Fix flaky compaction disable test by controlling delete concurrency#25794void-ptr974 wants to merge 1 commit into
void-ptr974 wants to merge 1 commit into
Conversation
CompactionConcurrencyTest.testDisableCompactionConcurrently verifies that only one __compaction subscription delete can run through the compaction disable path at a time. While one delete is waiting for the current compaction to finish and has set disablingCompaction=true, a second delete request should be rejected by the guard and returned to the admin client as PreconditionFailedException. The test was flaky because it created two deleteSubscriptionAsync requests from separate threads and assumed they would overlap. With the shared in-memory metadata store, the first request can delete the subscription before the second request reaches the broker. In that ordering the second request no longer exercises the concurrent-disable path, and both requests can complete successfully, making the assertion unreliable. Make the concurrent window deterministic by replacing the topic currentCompaction future with an incomplete future before starting the first __compaction delete. The first delete is then held in the disable path after setting disablingCompaction=true. The test waits for that state, sends the second delete, and verifies it fails with PulsarAdminException.PreconditionFailedException. It then completes the blocked compaction future and verifies the first delete finishes successfully and disablingCompaction is reset. The test now verifies the intended concurrent compaction-disable behavior without depending on thread scheduling or metadata-store timing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25775
Motivation
CompactionConcurrencyTest.testDisableCompactionConcurrentlyis flaky because it assumes two__compactionsubscription delete requests will overlap.With the shared in-memory metadata store, the first delete can finish before the second reaches the broker. In that case both requests may complete successfully, so the test does not
reliably verify the
disablingCompactionguard.Modifications
Make the concurrency window deterministic.
The test now blocks
currentCompactionbefore sending the first__compactiondelete, waits untildisablingCompaction=true, then sends the second delete and verifies it fails withPreconditionFailedException.After that, it completes the blocked compaction future and verifies the first delete succeeds and
disablingCompactionis reset.Verifying this change
This change updates an existing test and can be verified as follows:
Does this pull request potentially affect one of the following parts: