You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "CRZbulabula (via GitHub)" <gi...@apache.org> on 2026/05/18 13:19:44 UTC

[PR] Fix duplicate peer in createNewRegionPeer; harden reconstruct IT [iotdb]

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

   ## Description
   
   ### Fix duplicate peer entry in `createNewRegionPeer`
   
   `AddRegionPeerProcedure.CREATE_NEW_REGION_PEER` runs two steps back-to-back:
   
   ```java
   handler.addRegionLocation(regionId, targetDataNode);   // writes target into PartitionTable
   TSStatus status = handler.createNewRegionPeer(regionId, targetDataNode);
   ```
   
   `createNewRegionPeer` then reads the partition table back (which already contains `targetDataNode`) and unconditionally appends `destDataNode` again, so the `TCreatePeerReq` ships a duplicated peer — for example `[Peer{nodeId=2}, Peer{nodeId=3}, Peer{nodeId=3}]` when adding DN_3 to region 3.
   
   The duplicate is silently swallowed downstream (`IoTConsensus.createLocalPeer` wraps the list in a `TreeSet`; `IoTConsensusV2PeerManager` uses a `Set` and also logs a misleading `DUPLICATE_PEERS_IGNORED` WARN), so it has not produced a visible failure, but it (a) pollutes V2 logs with a WARN on every add-peer, (b) makes per-region migration logs hard to read, and (c) is fragile should anyone later use `peers.size()` for an invariant check.
   
   The fix is defensive: in the IoT-consensus branch, append `destDataNode` only when it is not already present in `regionReplicaNodes`. Behavior is identical to before for callers that do not pre-insert the target.
   
   Affects every caller of `AddRegionPeerProcedure`: `reconstruct region`, `migrate region`, `extend region`, and procedure restore.
   
   ### Tighten `IoTDBRegionReconstructForIoTV1IT.normal1C3DTest` await
   
   The post-`reconstruct` wait condition was:
   
   ```java
   () -> getRegionStatusWithoutRunning(session).isEmpty()
         && dataDirToBeReconstructed.getAbsoluteFile().exists()
   ```
   
   Both halves were weak:
   
   - `dataDirToBeReconstructed.exists()` is effectively always true — `deleteTsFiles` only removes files whose name ends in `.tsfile`, never the containing directory.
   - `getRegionStatusWithoutRunning(session).isEmpty()` is a negative check. When reconstruct rolled back, the reconstructed peer's row vanished from `show regions` briefly while the closed peer's status had not yet been refreshed from `Running` to `Unknown`, producing a ~3-second false-positive "everything is Running" window. The test then proceeded past the await, stopped the only live replica, and failed on the subsequent query loop with a misleading `Cannot execute query within 60s`.
   
   Replaced with a positive assertion: the selected region must contain both peers and both rows must report `Running`. Done via a new `getRegionStatusMap(Session)` helper that returns `regionId -> dataNodeId -> status`. On timeout, the test now logs the actual region status map for the selected region, which is the data you want for diagnosing why reconstruct did not finish.
   
   Also corrected the stale comment that claimed reconstruct happens "from the leader" — the code actually targets the surviving follower; the original leader is the replica that gets stopped and then restarted.
   
   <hr>
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   
   <hr>
   
   ##### Key changed/added classes (or packages if there are too many classes) in this PR
   
   - `org.apache.iotdb.confignode.procedure.env.RegionMaintainHandler`
   - `org.apache.iotdb.confignode.it.regionmigration.IoTDBRegionOperationReliabilityITFramework`
   - `org.apache.iotdb.confignode.it.regionmigration.pass.commit.IoTDBRegionReconstructForIoTV1IT`


-- 
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 duplicate peer in createNewRegionPeer; harden reconstruct IT [iotdb]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17710:
URL: https://github.com/apache/iotdb/pull/17710#issuecomment-4478143564

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17710) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17710&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17710&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=17710&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17710&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17710&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17710)
   
   


-- 
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 duplicate peer in createNewRegionPeer; harden reconstruct IT [iotdb]

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


-- 
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 duplicate peer in createNewRegionPeer; harden reconstruct IT [iotdb]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #17710:
URL: https://github.com/apache/iotdb/pull/17710#issuecomment-4478477157

   ## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/17710?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `2 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 40.38%. Comparing base ([`4ac0b7e`](https://app.codecov.io/gh/apache/iotdb/commit/4ac0b7ee029587d7a6f3393dcac24ca53fc0b7c3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`3fff9dd`](https://app.codecov.io/gh/apache/iotdb/commit/3fff9dd4030a3a49875b355ccf4f18538753d72b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/iotdb/pull/17710?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...onfignode/procedure/env/RegionMaintainHandler.java](https://app.codecov.io/gh/apache/iotdb/pull/17710?src=pr&el=tree&filepath=iotdb-core%2Fconfignode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fconfignode%2Fprocedure%2Fenv%2FRegionMaintainHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9jb25maWdub2RlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pb3RkYi9jb25maWdub2RlL3Byb2NlZHVyZS9lbnYvUmVnaW9uTWFpbnRhaW5IYW5kbGVyLmphdmE=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17710?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #17710      +/-   ##
   ============================================
   - Coverage     40.39%   40.38%   -0.01%     
   + Complexity     2575     2574       -1     
   ============================================
     Files          5179     5179              
     Lines        349659   349660       +1     
     Branches      44688    44689       +1     
   ============================================
   - Hits         141251   141225      -26     
   - Misses       208408   208435      +27     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/iotdb/pull/17710?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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