You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "Pengzna (via GitHub)" <gi...@apache.org> on 2026/02/28 09:10:11 UTC

[PR] Fix deadlock between DataNode createDataRegion and ConfigNode PipeTaskCoordinatorLock by delegating consensus pipe lifecycle to ConfigNode [iotdb]

Pengzna opened a new pull request, #17233:
URL: https://github.com/apache/iotdb/pull/17233

   NOTE: This PR is implemented by Claude Opus 4.6, 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:
   1. ConfigNode holds `PipeTaskCoordinatorLock` → `pushSinglePipeMeta` to DataNode (blocking)
   2. DataNode's `createDataRegion` handler → `PipeConsensusServerImpl` constructor → synchronous `createPipe` RPC back to ConfigNode → blocked by the same lock → timeout
   
   ## Solution
   
   Delegate all consensus pipe lifecycle management to ConfigNode, eliminating DN→CN synchronous pipe RPCs entirely.
   
   **ConfigNode side:**
   - `AddRegionPeerProcedure`: add `CREATE_CONSENSUS_PIPES` state — creates bidirectional pipes between new peer and existing peers before `DO_ADD_REGION_PEER`
   - `RemoveRegionPeerProcedure`: add `DROP_CONSENSUS_PIPES` state — drops related pipes after `DELETE_OLD_REGION_PEER`
   - `RegionMaintainHandler`: add helper methods to build `TCreatePipeReq` and invoke `ProcedureManager.createConsensusPipe/dropConsensusPipe`
   
   **DataNode side:**
   - `PipeConsensusServerImpl`: remove `createConsensusPipes` call from constructor (pipes are created by ConfigNode's procedure)
   - `ConsensusPipeDataNodeDispatcher`: convert to no-op (all 4 methods just return immediately)
   
   **Consistency guarantees:**
   - New DataRegion creation: ConfigNode already creates pipes via `CreatePipeProcedureV2`
   - Region migration: ConfigNode creates pipes deterministically in procedure before coordinator starts data transfer
   - `checkConsensusPipe` guardian still detects inconsistencies via logging; `peerManager` updates are preserved through existing P2P notification flow


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix deadlock between DataNode createDataRegion and ConfigNode PipeTaskCoordinatorLock by delegating consensus pipe lifecycle to ConfigNode [iotdb]

Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 commented on code in PR #17233:
URL: https://github.com/apache/iotdb/pull/17233#discussion_r2870927168


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/task/PipeTaskCoordinator.java:
##########
@@ -86,18 +86,11 @@ public AtomicReference<PipeTaskInfo> lock() {
    * Unlock the pipe task coordinator. Calling this method will clear the pipe task info holder,
    * which means that the holder will be null after calling this method.
    *
-   * @return {@code true} if successfully unlocked, {@code false} if current thread is not holding
-   *     the lock.
+   * @return {@code true} if successfully unlocked.
    */
   public boolean unlock() {
-    try {
-      pipeTaskCoordinatorLock.unlock();
-      return true;
-    } catch (IllegalMonitorStateException ignored) {
-      // This is thrown if unlock() is called without lock() called first.
-      LOGGER.warn("This thread is not holding the lock.");
-      return false;
-    }
+    pipeTaskCoordinatorLock.unlock();
+    return true;
   }

Review Comment:
   If the method always returns true, may remove the return value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix deadlock between DataNode createDataRegion and ConfigNode PipeTaskCoordinatorLock by delegating consensus pipe lifecycle to ConfigNode [iotdb]

Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 merged PR #17233:
URL: https://github.com/apache/iotdb/pull/17233


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix deadlock between DataNode createDataRegion and ConfigNode PipeTaskCoordinatorLock by delegating consensus pipe lifecycle to ConfigNode [iotdb]

Posted by "Pengzna (via GitHub)" <gi...@apache.org>.
Pengzna commented on code in PR #17233:
URL: https://github.com/apache/iotdb/pull/17233#discussion_r2876979283


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/task/PipeTaskCoordinator.java:
##########
@@ -86,18 +86,11 @@ public AtomicReference<PipeTaskInfo> lock() {
    * Unlock the pipe task coordinator. Calling this method will clear the pipe task info holder,
    * which means that the holder will be null after calling this method.
    *
-   * @return {@code true} if successfully unlocked, {@code false} if current thread is not holding
-   *     the lock.
+   * @return {@code true} if successfully unlocked.
    */
   public boolean unlock() {
-    try {
-      pipeTaskCoordinatorLock.unlock();
-      return true;
-    } catch (IllegalMonitorStateException ignored) {
-      // This is thrown if unlock() is called without lock() called first.
-      LOGGER.warn("This thread is not holding the lock.");
-      return false;
-    }
+    pipeTaskCoordinatorLock.unlock();
+    return true;
   }

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org