Skip to content

Fix duplicate scheduling in procedure execution#17902

Open
Caideyipi wants to merge 2 commits into
masterfrom
fix-procedure-duplicate-scheduling
Open

Fix duplicate scheduling in procedure execution#17902
Caideyipi wants to merge 2 commits into
masterfrom
fix-procedure-duplicate-scheduling

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Description

Prevent duplicate procedure execution

  • Add a per-procedure execution guard so a duplicated scheduler entry cannot run the same Procedure instance concurrently.
  • Release the guard, active executor count, and worker state in the worker finally path.
  • Release locks when a scheduled procedure is no longer RUNNABLE.

Avoid duplicate lock wakeups

  • De-duplicate LockQueue waiters by procedure id before adding a waiting procedure.
  • Keep PipeTaskCoordinatorLock waiting until a permit is actually acquired, even if the thread is already interrupted.

Tests

  • Add coverage for duplicate procedure scheduling, duplicate LockQueue wakeups, interrupted PipeTaskCoordinatorLock acquisition, and completed PipeHandleLeaderChangeProcedure equality.

This PR has:

  • been self-reviewed.
    • concurrent read
    • concurrent write
    • concurrent read and write
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage.

Key changed/added classes (or packages if there are too many classes) in this PR
  • org.apache.iotdb.confignode.procedure.Procedure
  • org.apache.iotdb.confignode.procedure.ProcedureExecutor
  • org.apache.iotdb.confignode.procedure.scheduler.LockQueue
  • org.apache.iotdb.confignode.manager.pipe.coordinator.task.PipeTaskCoordinatorLock
Local verification
  • PASS: mvn -pl iotdb-core/confignode spotless:apply
  • FAIL: mvn -pl iotdb-core/confignode -Dtest=TestLockRegime,TestProcedureExecutor,PipeHandleLeaderChangeProcedureTest,PipeTaskCoordinatorLockTest test failed during compile before test execution because local generated/snapshot dependencies were missing classes such as TGetCommitProgressReq, TPullCommitProgressReq, CommitProgressKeeper, and RegionProgress.

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.11765% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.76%. Comparing base (86987e4) to head (f6e2115).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
.../iotdb/confignode/procedure/ProcedureExecutor.java 63.88% 13 Missing ⚠️
...db/confignode/procedure/TimeoutExecutorThread.java 75.00% 4 Missing ⚠️
...otdb/db/schemaengine/table/DataNodeTableCache.java 50.00% 2 Missing ⚠️
...ode/procedure/impl/node/AbstractNodeProcedure.java 0.00% 1 Missing ⚠️
.../impl/schema/AlterTimeSeriesDataTypeProcedure.java 0.00% 1 Missing ⚠️
...ntime/SubscriptionHandleLeaderChangeProcedure.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17902      +/-   ##
============================================
+ Coverage     40.74%   40.76%   +0.01%     
  Complexity     2621     2621              
============================================
  Files          5245     5245              
  Lines        363136   363155      +19     
  Branches      46762    46769       +7     
============================================
+ Hits         147960   148026      +66     
+ Misses       215176   215129      -47     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant