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/06/11 04:08:34 UTC

[PR] Fix MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## Problem
   
   When the ConfigNode leader is **gracefully** stopped — or otherwise loses leadership — while `AddRegionPeerProcedure` is in `DO_ADD_REGION_PEER` waiting for the coordinator DataNode's AddRegionPeer task to finish, `MIGRATE REGION` could be reported as **successful while the destination replica had not actually received the snapshot**, and the source replica was already removed. Queries against the region returned incorrect results during the gap.
   
   ### Reproduction (field case)
   
   `MIGRATE REGION 1 FROM 3 TO 4`, then stop the current ConfigNode leader right after the source replica started transmitting the snapshot (an 8.85 GB region over IoTConsensus). Observed:
   
   - ConfigNode printed `[MigrateRegion] success` and `show migrations` was already empty;
   - `show regions` showed the destination replica as Running/Leader;
   - but the destination DataNode only actually loaded the snapshot and became active **~17.5 minutes later**.
   
   During that window the source replica was already deleted while the destination was still `Adding`, so query results were wrong.
   
   ### Root cause
   
   `RegionMaintainHandler.waitTaskFinish()` returns `PROCESSING` **only** when its polling loop is interrupted by an `InterruptedException` (ConfigNode shutdown / leadership loss). A user `CANCEL` or a coordinator disconnection both go through the `FAIL` branch instead, so `PROCESSING` unambiguously means "interrupted by shutdown/leader switch".
   
   The old `DO_ADD_REGION_PEER` code treated `PROCESSING` as a terminal no-op (`return Flow.NO_MORE_STATE`), silently ending `AddRegionPeerProcedure` with neither success nor rollback. The parent `RegionMigrateProcedure` had already persisted at `CHECK_ADD_REGION_PEER`, so the new leader resumed there directly. That check uses `isDataNodeContainsRegion()`, which only inspects the partition table's **location list** — and the location is written back at `CREATE_NEW_REGION_PEER`, long before the snapshot finishes transferring. So the check passed, the source replica was removed, and the migration was declared complete prematurely.
   
   ## Fix
   
   In the `DO_ADD_REGION_PEER` `PROCESSING` branch, **stay at `DO_ADD_REGION_PEER` and persist it** (`HAS_MORE_STATE`) instead of ending. After recovery, the new leader re-enters `DO_ADD_REGION_PEER` and re-polls the coordinator task until it truly reaches `SUCCESS` or `FAIL`, so the parent only advances to `REMOVE_REGION_PEER` once the destination replica is genuinely added.
   
   The re-poll is **idempotent**, so the AddRegionPeer task is never submitted twice:
   
   - After a restart / leader switch, the `isStateDeserialized()` guard skips re-submitting the task and only re-polls;
   - Even in a same-process immediate re-execute, the coordinator DataNode dedups by `taskId` (`taskResultMap.putIfAbsent`), so a duplicate submit is a no-op;
   - If the coordinator crashed and lost its task table, the poll returns `TASK_NOT_EXIST`, which falls through to the existing `FAIL` / rollback path (safe degradation).
   
   The `waitTaskFinish() returns PROCESSING ...` log message (en + zh) is updated to reflect the new behavior.
   
   ## Tests
   
   Adds `cnLeaderSwitchDuringDoAddPeerTest` for each consensus protocol — IoTConsensus, IoTConsensusV2 (batch & stream), and Ratis.
   
   The existing daily ConfigNode-crash ITs all use `stopForcibly()` (SIGKILL), which kills the process before it can run the `PROCESSING` branch, so this path was never covered. The new test introduces a graceful `stop()` (SIGTERM) action and stops the **leader** among 3 ConfigNodes, so the interrupted `PROCESSING` path is actually exercised across a real leader switch, and asserts the migration still completes correctly (destination Running, source removed).
   
   > Note: the new tests are temporarily tagged `@Category({DailyIT.class, ClusterIT.class})` so they also run on the per-PR `Cluster IT - 1C3D` job for validation. This will be reverted to `DailyIT`-only before merge.


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

Posted by "Caideyipi (via GitHub)" <gi...@apache.org>.
Caideyipi commented on PR #17908:
URL: https://github.com/apache/iotdb/pull/17908#issuecomment-4678002282

   我看了这次修复,主要有两个点建议再处理一下:
   
   1. `AddRegionPeerProcedure` 的 `PROCESSING` 分支现在通过 `setNextState(AddRegionPeerState.DO_ADD_REGION_PEER)` + `HAS_MORE_STATE` 留在当前状态,但在这个 procedure 框架里这不只是“持久化后等待恢复”。`StateMachineProcedure.execute()` 会返回 `new Procedure[] {this}`,`ProcedureExecutor` 对 `subprocs.length == 1 && subprocs[0] == proc` 会设置 `reExecute = true`,也就是在同一个 worker 的同一次 `executeProcedure` 循环里立即重入。再加上 `waitTaskFinish()` 捕获 `InterruptedException` 后会重新设置 interrupt flag 并返回 `PROCESSING`,下一轮进入 `waitTaskFinish()` 时 `sleep(1)` 可能立刻再次被中断,于是形成重复 submit/poll 循环;shutdown 时 worker 也不会因为 `running=false` 退出这个内层 reExecute 循环。建议在框架层避免 stopped executor 继续 reExecute,或者让这个分支真正 yield/退出当前执行轮次,而不是依赖 `HAS_MORE_STATE` 的即时重入语�
 �。
   
   2. 新增的 `cnLeaderSwitchDuringDoAddPeerTest` 只等待 `DO_ADD_REGION_PEER` kill point 被触发并验证最终迁移成功,但 kill point 在 submit 后、`waitTaskFinish()` 前。如果 AddPeer 很快完成,测试仍可能走 `SUCCESS` 分支并通过,没有实际覆盖这次新增的 `PROCESSING` 分支。建议额外断言 `waitTaskFinish() returns PROCESSING` 这条日志出现,或者用更确定的 DataNode-side kill point/延迟确保 `waitTaskFinish()` 被 graceful stop 中断。


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [![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=17908) **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=17908&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=17908&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=17908&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=17908&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=17908&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17908)
   
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [![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=17908) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17908&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=17908&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=17908&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=17908&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=17908&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17908)
   
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [![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=17908) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [7 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17908&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=17908&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=17908&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=17908&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.7% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=17908&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17908)
   
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [![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=17908) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17908&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=17908&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=17908&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=17908&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=17908&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17908)
   
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

Posted by "CRZbulabula (via GitHub)" <gi...@apache.org>.
CRZbulabula commented on PR #17908:
URL: https://github.com/apache/iotdb/pull/17908#issuecomment-4704393359

   Addressed in 37317b6602: removed the temporary ClusterIT category/import/comment from the four cnLeaderSwitchDuringDoAddPeerTest methods, so they now rely only on the class-level DailyIT category.


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [![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=17908) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=17908&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=17908&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=17908&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=17908&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=17908&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17908)
   
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/17908?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.83%. Comparing base ([`a725ded`](https://app.codecov.io/gh/apache/iotdb/commit/a725ded24717b54383401e11aa5e3680459a152c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b5fda9d`](https://app.codecov.io/gh/apache/iotdb/commit/b5fda9d703890801fae31dc554ce09d7727f836f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/iotdb/pull/17908?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [.../procedure/impl/region/AddRegionPeerProcedure.java](https://app.codecov.io/gh/apache/iotdb/pull/17908?src=pr&el=tree&filepath=iotdb-core%2Fconfignode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fconfignode%2Fprocedure%2Fimpl%2Fregion%2FAddRegionPeerProcedure.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9jb25maWdub2RlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pb3RkYi9jb25maWdub2RlL3Byb2NlZHVyZS9pbXBsL3JlZ2lvbi9BZGRSZWdpb25QZWVyUHJvY2VkdXJlLmphdmE=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/17908?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   #17908   +/-   ##
   =========================================
     Coverage     40.82%   40.83%           
     Complexity      318      318           
   =========================================
     Files          5245     5245           
     Lines        363203   363204    +1     
     Branches      46780    46780           
   =========================================
   + Hits         148287   148322   +35     
   + Misses       214916   214882   -34     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/iotdb/pull/17908?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


Re: [PR] Fix MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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

   ## [![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=17908) **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=17908&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=17908&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=17908&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=17908&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=17908&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=17908)
   
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

Posted by "CRZbulabula (via GitHub)" <gi...@apache.org>.
CRZbulabula commented on PR #17908:
URL: https://github.com/apache/iotdb/pull/17908#issuecomment-4678900296

   Thanks @Caideyipi, both points are valid — fixed in 6dd498e.
   
   **1. Re-execution loop on shutdown.** You're right that `setNextState(DO_ADD_REGION_PEER)` + `HAS_MORE_STATE` triggers the in-place `reExecute` path (`subprocs[0] == proc`), and that `store.isRunning()` is not a sufficient exit condition: `stopExecutor()` runs `executor.stop()` and `executor.join()` *before* `store.stop()`, so during shutdown the store is still running while `join()` waits for this very worker — the inner loop would keep re-submitting/re-polling and `join()` would hang. (I also checked throwing `InterruptedException` to yield instead: that doesn't work here, because after the `catch (InterruptedException)` in `executeProcedure` the procedure falls through to `setState(SUCCESS)`, which is exactly the false-success we're trying to avoid.)
   
   Fix at the framework layer: the inner loop now also checks the executor's own running flag — `if (!isRunning() || !store.isRunning()) return;` — so the worker exits cleanly when the executor is stopping, and the persisted state lets the next leader resume. Hardening at the procedure layer: the AddRegionPeerTask is now submitted only when `getCycles() == 0` (first entry) in addition to the existing `isStateDeserialized()` guard, so an in-place re-entry never re-submits.
   
   **2. The test could miss the PROCESSING branch.** Correct, and worse than theoretical — I checked the logs of the previous (green) CI run and there is **no** `returns PROCESSING` line, i.e. the kill point fired after submit but before `waitTaskFinish()`, AddPeer finished quickly, and the test passed via the SUCCESS branch without ever exercising the new code.
   
   Fix: I added a `RegionMaintainKillPoints.WAIT_TASK_FINISH_POLLING` kill point that fires from *inside* `waitTaskFinish()`, once the first poll confirms the task is still `PROCESSING` — i.e. when the worker is provably blocked in the wait. The graceful stop then deterministically interrupts `waitTaskFinish()`. The test registers this kill point instead of `DO_ADD_REGION_PEER`, and additionally asserts that a ConfigNode log contains `returns PROCESSING`, so it now fails loudly if the branch is skipped.
   
   I'll re-run the tests on the per-PR Cluster IT pipeline to confirm the PROCESSING branch is now actually hit before finalizing.
   


-- 
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 MIGRATE REGION falsely reported complete when ConfigNode leader switches during AddRegionPeer [iotdb]

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


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