Draft: Fix deadlock between DataNode createDataRegion and ConfigNode PipeTaskCoordinatorLock by delegating consensus pipe lifecycle to ConfigNode#17233
Open
Pengzna wants to merge 8 commits intoapache:masterfrom
Conversation
…kCoordinatorLock by delegating consensus pipe lifecycle to ConfigNode
… was removed failed to clear region file
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.
NOTE: This PR is genereated by Claude, I proposed the entire plans and prompts and have carefully reviewed this PR.
Problem
When using IoTConsensusV2, cluster initialization may deadlock during DataRegion creation (e.g., for
root.__audit), causing "After 30 times retry, the cluster can't work!".Root cause: Circular dependency between DataNode and ConfigNode:
PipeTaskCoordinatorLock→**pushSinglePipeMeta**to DataNode (blocking)DataNodeInternalRPCServiceImpl.pushSinglePipeMeta
→ PipeTaskAgent.handleSinglePipeMetaChanges
→ PipeTaskAgent.createPipe
→ PipeDataNodeTaskBuilder.build
→ IoTDBDataRegionSource.customize
→ IoTDBDataRegionSource.login
→ SessionManager.login
→ DataNodeAuthUtils.recordPasswordHistory
→ Coordinator.executeForTreeModel (INSERT audit data)
→ ClusterPartitionFetcher.getOrCreateDataPartition
→ ConfigNodeClient.getOrCreateDataPartitionTable (sync RPC call ConfigNode)
→ SocketTimeoutException: Read timed out
**createDataRegion**handler →PipeConsensusServerImplconstructor → synchronouscreatePipeRPC back to ConfigNode → blocked by the same lock → timeoutConfigNode. CreateRegionGroupsProcedure ->DataNodeRegionManager.createDataRegion (line 157)
→ PipeConsensus.createLocalPeer
→ PipeConsensusServerImpl. (line 124)
→ createConsensusPipes
→ ConsensusPipeDataNodeDispatcher.createPipe (line 66)
→ ConfigNodeClient.createPipe (sync RPC call ConfigNode)
Solution
Delegate all consensus pipe lifecycle management to ConfigNode, eliminating DN→CN synchronous pipe RPCs entirely.
ConfigNode side:
AddRegionPeerProcedure: addCREATE_CONSENSUS_PIPESstate — creates bidirectional pipes between new peer and existing peers beforeDO_ADD_REGION_PEERRemoveRegionPeerProcedure: addDROP_CONSENSUS_PIPESstate — drops related pipes afterDELETE_OLD_REGION_PEERRegionMaintainHandler: add helper methods to buildTCreatePipeReqand invokeProcedureManager.createConsensusPipe/dropConsensusPipeDataNode side:
PipeConsensusServerImpl: removecreateConsensusPipescall from constructor (pipes are created by ConfigNode's procedure)ConsensusPipeDataNodeDispatcher: convert to no-op (all 4 methods just return immediately)Consistency guarantees:
CreatePipeProcedureV2checkConsensusPipeguardian still detects inconsistencies via logging;peerManagerupdates are preserved through existing P2P notification flow