Fix subscription consumer lifecycle state ordering#18151
Open
Caideyipi wants to merge 1 commit into
Open
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #18151 +/- ##
============================================
- Coverage 41.87% 41.85% -0.03%
Complexity 318 318
============================================
Files 5297 5297
Lines 374168 374180 +12
Branches 48302 48304 +2
============================================
- Hits 156693 156608 -85
- Misses 217475 217572 +97 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jt2594838
approved these changes
Jul 8, 2026
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.


Description
This PR fixes subscription consumer lifecycle state ordering for both push and pull consumers.
Concrete failure scenario
A push or pull subscription consumer calls
open().AbstractSubscriptionConsumer.open()opens providers and submits the heartbeat and endpoint-sync workers before the push/pull subclass flips its ownisClosedflag tofalse. If either scheduled worker runs immediately, the worker dispatches to the subclassisClosed()override, observes the consumer as closed, cancels its own future, and leaves the already-open consumer without heartbeat or endpoint synchronization.A symmetric close path can also leak providers: push/pull
close()previously called the base close before marking the subclass closed. During that window, an endpoint-sync task can still treat the consumer as open and reopen subscription providers after close has begun.Fix
Tests
mvn spotless:apply -pl iotdb-client/subscriptionmvn -pl iotdb-client/subscription -Dtest=SubscriptionConsumerLifecycleTest testmvn -pl iotdb-client/subscription testmvn -pl iotdb-client/subscription -P with-zh-locale -DskipTests test-compileThis PR has:
Key changed/added classes (or packages if there are too many classes) in this PR
org.apache.iotdb.session.subscription.consumer.base.AbstractSubscriptionPushConsumerorg.apache.iotdb.session.subscription.consumer.base.AbstractSubscriptionPullConsumerorg.apache.iotdb.session.subscription.consumer.base.AbstractSubscriptionProvidersorg.apache.iotdb.session.subscription.consumer.base.SubscriptionConsumerLifecycleTest