Repository navigation
Conversation
| regionLeaders.entrySet().iterator().next(); | ||
| final int targetRegionId = targetRegionLeader.getKey(); | ||
| final DataNodeWrapper oldLeader = targetRegionLeader.getValue(); | ||
| oldLeader.stopForcibly(); |
There was a problem hiding this comment.
minor integration-test/src/test/java/org/apache/iotdb/subscription/it/consensus/local/tablemodel/IoTDBConsensusSubscriptionLeaderFailoverTableIT.java:129 — New failover IT never reaches the preferredWriterChanged reset branch
The future leader's queue is bound with initialActive = (lastKnownPreferredWriter == myNodeId), i.e. false, so the first state carrying preferredWriterNodeId == itself already satisfies the pre-existing !isActive term and runs the same authoritative refresh/seek. With only one leader change, the new preferredWriterChanged term is never exercised, so this IT passes with or without the queue change.
Fix: Add a second leader change (e.g. also kill the new leader, or re-elect back to the surviving replica) so an already-active queue observes a preferred-writer change, or drive applyRuntimeState twice on an active queue as the unit test does.
There was a problem hiding this comment.
Added a second forced DataRegion leader failover. The delivery assertion now covers rows queued before that transition and rows written afterward. Spotless and the integration-test selection check pass; the targeted IT was not run locally.
|
Addressed the review feedback by adding a second forced DataRegion leader failover and asserting delivery of rows queued before and written after that transition. Spotless and the integration-test selection check passed. The targeted integration test was not run locally. |
| && commitManager.isConfigNodeProgressAvailable( | ||
| consumerGroupId, topicName, consensusGroupId); | ||
| final boolean requiresAuthoritativeActivation = | ||
| runtimeState.isActive() && (!isActive || preferredWriterChanged); |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/consensus/ConsensusPrefetchingQueue.java:6104 — preferredWriterChanged can never be true for an active queue, so failover replay is unchanged
isActive only becomes true by applying a state whose active flag is true, and all producers set active = (preferredWriterNodeId == local node id) (SetupHandler:273/1310, ConfigNodeProcedureEnv:1043), storing that same id at line 6118. Any later active state therefore already carries the stored preferredWriterNodeId, so this term never fires; the CN push after SubscriptionHandleLeaderChangeProcedure (same leader, newer runtimeVersion, fresher checkpoint) still does not refresh.
Fix: Refresh on progress instead of writer identity: force the authoritative activation when runtimeState.getRuntimeVersion() > this.runtimeVersion and ConfigNode progress is available.
There was a problem hiding this comment.
Thanks for identifying the unreachable condition. The refresh trigger now performs authoritative activation when an active queue receives a strictly newer runtimeVersion and ConfigNode progress is available, even when the preferred writer ID is unchanged. The unit test now asserts this active-queue case.
| ids.getDatabase(), survivingNode, targetRegionId, oldLeader); | ||
| final Set<String> rowsAfterFailover = | ||
| insertRows(newLeader, ids.getDatabase(), tableName, 3_000L, 32); | ||
| newLeader.stopForcibly(); |
There was a problem hiding this comment.
minor integration-test/src/test/java/org/apache/iotdb/subscription/it/consensus/local/tablemodel/IoTDBConsensusSubscriptionLeaderFailoverTableIT.java:142 — IT kills a leader right after ACKed inserts and relies on async WAL replication
IoTConsensusServerImpl.write returns after the local state-machine write and replicates asynchronously afterwards. rowsAfterFailover (line 141) and rowsBeforeFailover are part of expectedRows, yet stopForcibly() runs immediately after insertRows returns, so entries not yet shipped to a surviving replica are lost and the final containsAll assertion fails intermittently.
Fix: Wait until a surviving replica has applied those entries (e.g. poll its subscription progress/search index) before stopForcibly(), or flush and pause before killing.
There was a problem hiding this comment.
Added a bounded wait before each forced stop. It compares the leader searchIndex with the per-peer currentSyncIndex for every surviving replica, so each pre-stop batch is replicated before the next failover. The targeted 1C3D integration test passes.
|
Review-comment handling summary\n\n- Active queues now refresh authoritative progress for a newer runtimeVersion when ConfigNode progress is available, including when the preferred writer ID is unchanged.\n- The 1C3D failover IT enables Prometheus metrics, waits for surviving replicas to catch up before both forced stops, and verifies queued-row delivery after the second failover.\n- Verification passed: Spotless, IT selection check (710 classes), DataNode unit test (10/10), and targeted TableClusterIT (1/1). A temporary subscription-enabled source override was used only for verification and reverted; it is not in the commit.\n- Reviewed PR head: db8527a. Final local and confirmed remote head: acabee2. |
| && commitManager.isConfigNodeProgressAvailable( | ||
| consumerGroupId, topicName, consensusGroupId); | ||
| final boolean requiresAuthoritativeActivation = | ||
| runtimeState.isActive() && (!isActive || shouldRefreshAuthoritativeProgress); |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/consensus/ConsensusPrefetchingQueue.java:6098 — Active-queue refresh rescans WAL for every region on any node status change
shouldRefreshAuthoritativeProgress fires on any newer runtimeVersion, and handleNodeStatisticsChange bumps that version for every DataRegion when any DataNode toggles mayBeOffline. Each push then runs setActive(false), a sync ConfigNode fetch and locateReplayStartForRegionProgress, which scans the WAL from Long.MIN_VALUE and rolls the WAL file, per region x topic, though nothing changed for that region.
Fix: Only tear down and re-seek when the fetched ConfigNode progress for this (group, topic, region) actually exceeds the queue's committed frontier, so unrelated node-status pushes do not deactivate and fully rescan every active queue.
|
minor Because the refresh now calls Fix: Fail pending user seeks only when the incoming runtime state is inactive/closing; for active->active version refreshes let the explicit seek win, since seekGeneration already fences the older lookup. |
Summary
Tests
ConsensusPrefetchingQueueSeekTest: 10 tests passed.IoTDBConsensusSubscriptionLeaderFailoverTableIT#testSubscriptionContinuesAfterKill9RegionLeaderFailover: 1 test passed. Local validation temporarily enabled the subscription feature gate; that verification-only source change is not included.