Skip to content

Fix concurrent subscription consumer handshakes - #18654

Open
Caideyipi wants to merge 3 commits into
apache:masterfrom
Caideyipi:fix/subscription-consumer-session-fenced
Open

Caideyipi wants to merge 3 commits into
apache:masterfrom
Caideyipi:fix/subscription-consumer-session-fenced

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

What is changed

  • Serialize handshakes for the same subscription consumer identity and atomically transfer ownership to one connection.
  • Give each consumer instance a transient, ordered consumer-instance-id shared by all of its DataNode handshakes, so every DataNode chooses the same winner even when requests arrive in different orders. Legacy clients retain arrival-order behavior, and the transient ID is removed before consumer attributes are persisted to ConfigNode.
  • Fence the losing receiver with status 1919 so stale heartbeats, subscriptions, polls, commits, closes, and handshakes cannot affect the active consumer.
  • Treat consumer fencing as a terminal client state: stop background workers and reconnect attempts, close only transport sessions, discard sibling parallel-poll results, and fail async commits with the original fencing exception without consuming their message iterable.
  • Add English/Chinese messages and regression tests for concurrent and cross-DataNode handshake ordering, late handshakes/exits, client lifecycle, poll handling, and async commit handling.

Verification

  • mvn spotless:apply (passed)
  • git diff --check (passed)
  • mvn -nsu test -pl iotdb-client/subscription '-Dtest=SubscriptionConsumerLifecycleTest,SubscriptionProviderStatusTest,SubscriptionConsumerConnectionFailureTest' '-DforkCount=0' (13 passed after rebasing onto current master)
  • mvn -nsu test -pl iotdb-core/datanode '-Dtest=SubscriptionReceiverAgentTest,SubscriptionReceiverV1Test' '-DforkCount=0' (25 passed before the latest rebase; git range-diff confirms the server-side patch is unchanged)
  • Full English and Chinese reactor compilation: pending the current PR CI run

@Caideyipi
Caideyipi force-pushed the fix/subscription-consumer-session-fenced branch from 76fae97 to 91393be Compare September 17, 2026 03:16
@Caideyipi
Caideyipi force-pushed the fix/subscription-consumer-session-fenced branch from 91393be to 10f6a89 Compare September 17, 2026 03:39
…scription-consumer-session-fenced

# Conflicts:
#	iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/consumer/base/AbstractSubscriptionConsumer.java
#	iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/consumer/base/AbstractSubscriptionProviders.java
#	iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/consumer/base/AbstractSubscriptionPullConsumer.java
#	iotdb-client/subscription/src/test/java/org/apache/iotdb/session/subscription/consumer/base/SubscriptionConsumerLifecycleTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants