Skip to content

refactor(server): disable legacy master-worker scheduler logic#3082

Merged
imbajin merged 18 commits into
apache:masterfrom
hugegraph:fix/scheduler
Jul 8, 2026
Merged

refactor(server): disable legacy master-worker scheduler logic#3082
imbajin merged 18 commits into
apache:masterfrom
hugegraph:fix/scheduler

Conversation

@Tsukilc

@Tsukilc Tsukilc commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR soft-disables the pre-PD master-worker task scheduling path while keeping old configs and task data upgrade-safe. Scheduler selection is now backend-driven: hstore uses DistributedTaskScheduler, and other backends use the local StandardTaskScheduler.

Before -> After

Before:

  • task.scheduler_type selected the scheduler mode.
  • The local scheduler used server_info, heartbeat, server load, and master/worker role election.
  • Normal tasks moved through SCHEDULING -> SCHEDULED -> QUEUED -> RUNNING, with the master assigning tasks to workers.

After:

  • task.scheduler_type is deprecated and ignored; old config files only emit a warning.
  • Non-HStore graphs use a direct local path: QUEUED -> local executor, with no master-worker assignment.
  • HStore graphs use the distributed scheduler, coordinated by task status and task locks instead of legacy server_info.
  • ServerInfoManager and role-election startup are kept only as soft-disabled compatibility shims.

Compatibility and Impact

  • Existing completed task records and task results remain readable and deletable.
  • Legacy SCHEDULING / SCHEDULED tasks from the old master-worker path are preserved in storage but are not restored or executed automatically. Operators should drain or cancel old in-flight master-worker tasks before upgrading if those tasks still matter.
  • server.role_election, server.id, and task.scheduler_type no longer control scheduling behavior.
  • Distributed delete/cancel handling is minimally hardened: DELETING is used as a retryable tombstone, running task deletion waits for the runner lifecycle, and save-after-delete resurrection is guarded.

Follow-up Cleanup

This PR is the first soft-disable step, not the final physical deletion. Some deprecated config, role-election, and server_info code is intentionally left as compatibility scaffolding for this transition. After the soft-disable behavior is verified as stable, follow-up PRs should mark and remove the remaining dead paths, especially:

  • unused server_info persistence, heartbeat, load, and worker-picking code paths;
  • role-election listener/state-machine wiring that no longer participates in scheduling;
  • deprecated scheduler config transfer/removal leftovers;
  • transition-only compatibility tests once the legacy path is fully removed.

The intended end state is to fully remove the old master-worker scheduling system after this compatibility window, while keeping the PD/HStore distributed scheduler as the only distributed scheduling path.

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. bug Something isn't working tests Add or improve test cases labels Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 234 lines in your changes missing coverage. Please review.
✅ Project coverage is 1.47%. Comparing base (03e6b8e) to head (69d11fe).

Files with missing lines Patch % Lines
...pache/hugegraph/task/DistributedTaskScheduler.java 0.00% 148 Missing ⚠️
...n/java/org/apache/hugegraph/core/GraphManager.java 0.00% 31 Missing ⚠️
...g/apache/hugegraph/task/StandardTaskScheduler.java 0.00% 28 Missing ⚠️
.../apache/hugegraph/task/TaskAndResultScheduler.java 0.00% 12 Missing ⚠️
...n/java/org/apache/hugegraph/StandardHugeGraph.java 0.00% 7 Missing ⚠️
...a/org/apache/hugegraph/task/ServerInfoManager.java 0.00% 5 Missing ⚠️
.../main/java/org/apache/hugegraph/task/HugeTask.java 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (03e6b8e) and HEAD (69d11fe). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (03e6b8e) HEAD (69d11fe)
3 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #3082       +/-   ##
============================================
- Coverage     36.80%   1.47%   -35.33%     
+ Complexity      338      21      -317     
============================================
  Files           805     783       -22     
  Lines         68587   65889     -2698     
  Branches       9029    8545      -484     
============================================
- Hits          25241     975    -24266     
- Misses        40653   64830    +24177     
+ Partials       2693      84     -2609     

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

bitflicker64 and others added 10 commits July 6, 2026 17:57
…letes are recoverable

When delete(force=true) is called and deleteFromDB() throws (e.g. result
vertex removal fails), the task must be left as DELETING so cronSchedule()
can retry. Previously the force-delete path skipped the status transition
entirely, leaving the task as SUCCESS — unrecoverable.
…and review issues

- Remove DELETING guard from TaskAndResultScheduler.save() — it blocked
  legitimate DELETING writes from updateStatus(), causing testTask:96
  failure. The resurrect-race is already handled by HugeTask.cancel().
- Write DELETING status before deleteFromDB() in force-delete path so
  failed deletions are recoverable via cronSchedule(). Reuse existing
  task variable instead of re-querying DB.
- Fix potential NPE in cronSchedule(): replace containsKey()+get() with
  get()+null-check on runningTasks ConcurrentHashMap.
- Remove commented-out code and fix todo→TODO in close().
- Fix thread leak in TaskSchedulerServerInfoTest: wrap constructor in
  try block so executors are shut down on failure.
tasks(ImmutableList.of(id)) defaults to withResult=false and returns
tasks without result, but the test expected the result field to be
present. Pass explicit withResult=true to use queryTask(ids) path.
…i review fixes

- GraphManager.initNodeRole(): add NullPointerException guard on role
  before toUpperCase()
- StandardTaskScheduler.cancel(): overwrite task status to CANCELLED
  on successful cancel for consistency with DistributedTaskScheduler
- ignore deprecated task.scheduler_type for upgrade compatibility
- avoid restoring legacy master-worker task statuses
- harden distributed task deletion against save races
- add focused task scheduler regression coverage
- avoid physically deleting locally running distributed tasks before runner exit
- keep force delete on running tasks in DELETING and cancel flow
- fail scheduler close when running tasks cannot drain in time
- add hstore regression coverage for force deleting running tasks
- inject PD peers for hstore backend case-insensitively
- keep queued task persistence after local queue admission
- harden task cleanup and GraphManager test lifecycle
- cover queue-full scheduling and mixed-case hstore config
- cancel locally running standard tasks before force deletion
- tolerate missing distributed tasks during cancel retry
- add regression coverage for delete and cancel races

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: cleanup legacy code/configs in phrase2

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 8, 2026
@imbajin imbajin changed the title fix(server): fix the scheduler and the scheduler selection logic refactor(server): disable legacy master-worker scheduler logic Jul 8, 2026
@imbajin imbajin merged commit 2d63804 into apache:master Jul 8, 2026
14 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files. tests Add or improve test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants