Skip to content

refactor(server): remove legacy scheduler code [p2] - #3244

Merged
imbajin merged 2 commits into
apache:masterfrom
byteayan:refactor/scheduler-phase2-cleanup
Sep 30, 2026
Merged

imbajin merged 2 commits into
apache:masterfrom
byteayan:refactor/scheduler-phase2-cleanup

Conversation

@byteayan

@byteayan byteayan commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of the PR

#3082 turned off the pre-PD master-worker scheduler but left the role election wiring, the deprecated config handling and ServerInfoManager's persistence path in place as compatibility scaffolding. This removes them.

Main Changes

Role election (first commit):

  • Delete the masterelection classes except GlobalMasterInfo (still used by RedirectFilter, ServerInfoManager, the Gremlin whitelist and examples), StandardRoleListener, and RoleElectionStateMachineTest.
  • Drop HugeGraph.roleElectionStateMachine() and its two implementations.
  • Remove server.role_election and the server.role.* options, including the RegisterUtil registration and the code in GraphManager and StandardAuthenticator that copied them into every graph config.
  • Remove the deprecation warnings refactor(server): disable legacy master-worker scheduler logic #3082 added for task.scheduler_type and server.role_election.
  • Remove TaskManager's task-scheduler pool, closeSchedulerTx() and the onAsRoleMaster/Worker no-ops.

Server info (second commit):

  • Delete HugeServerInfo.
  • Remove ServerInfoManager.init(), heartbeat(), tx(), call() and its db executor, plus the server-info-db-worker pool and the constructor parameter threaded through StandardTaskScheduler, TaskAndResultScheduler and DistributedTaskScheduler.

Where this differs from the plan in the issue:

  • The issue says DistributedTaskScheduler uses selfNodeId()/selfIsMaster(). Nothing calls them today; I kept them anyway since ServerInfoManager and TaskScheduler.serverManager() stay.
  • There was no initSchemaIfNeeded() call for HugeServerInfo to remove.
  • HugeVertex.type() still maps ~server and ~role_data to HugeType.SERVER, now through string literals, so vertices left in existing graphs keep routing to the same table on hstore.
  • The two transition tests are kept and renamed instead of deleted. They now check that a graph still opens with task.scheduler_type set, and that GraphManager starts and applies server.role when the removed role election keys are present.

Migration notes (for the release notes)

Java API, source and binary incompatible:

  • HugeGraph.roleElectionStateMachine() is removed, together with the types it exposed: RoleElectionStateMachine, StandardRoleElectionStateMachine, RoleListener, StandardRoleListener, StateMachineContext, ClusterRole, ClusterRoleStore, StandardClusterRoleStore, Config, RoleElectionConfig and RoleElectionOptions in org.apache.hugegraph.masterelection. Code compiled against 1.7.0 that calls it fails with NoSuchMethodError or NoClassDefFoundError. In 1.7.0, server.role_election=true started this state machine to elect a master among REST servers; refactor(server): disable legacy master-worker scheduler logic #3082 (not yet released) already stopped starting it, so the behavior change for 1.7.0 users comes from refactor(server): disable legacy master-worker scheduler logic #3082 and this PR only removes the unused API. Callers should delete the call. For task scheduling across several servers, use the hstore backend, which uses DistributedTaskScheduler; other backends use the local StandardTaskScheduler. The node role still comes from server.role through GlobalMasterInfo.
  • HugeServerInfo is removed, as are ServerInfoManager.init() and heartbeat(), which were no-ops. The ServerInfoManager, StandardTaskScheduler, TaskAndResultScheduler and DistributedTaskScheduler constructors drop their last ExecutorService (server info db executor) parameter; callers pass the remaining arguments unchanged.

Configuration: server.role_election and the server.role.* options are no longer registered. Remove them from rest-server.properties. A config that still sets them starts normally, and HugeConfig logs one "redundant option" warning per key.

I went with notes instead of a deprecated bridge because #3082 set no removal version for these APIs, and a bridge would have to keep the deleted RoleElectionStateMachine type alive only to return a machine nothing starts.

Left for a follow-up (#3245): GlobalMasterInfo.supportElection is never set to true any more, so the redirect branch in RedirectFilter is dead, and GraphTransaction.queryServerInfos() has no callers.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • TaskSchedulerServerInfoTest.testLegacyServerLabelsKeepServerType checks the legacy label mapping in HugeVertex
    • TaskSchedulerServerInfoTest.testGraphManagerIgnoresRemovedRoleElectionOptions and MultiGraphsTest.testOpenGraphWithRemovedTaskSchedulerType cover old config keys
    • Ran locally on JDK 11: the full UnitTestSuite (747 run, 0 failures) and the rocksdb core tests TaskAndResultSchedulerTest, MultiGraphsTest, TaskCoreTest (30 run, 0 failures)

Does this PR potentially affect the following parts?

"The public API" here is the Java HugeGraph interface losing roleElectionStateMachine(); no REST endpoint changes.

Documentation Status

Select one option and provide the documentation location when applicable.

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: no user-visible documentation is affected.

Documentation files in this PR or paired hugegraph-doc PR:
Paired hugegraph-doc PR: apache/hugegraph-doc#502 (removes server.role_election and the server.role.* block from content/{en,cn}/docs/config/config-option.md). Please merge both together.

Nothing has started the role election state machine since apache#3082.
Graphs started with a node id (tests, examples, and Gremlin scripts
calling serverStarted(GlobalMasterInfo.master(...))) still built one,
which wrote ~role_data schema and leaked an idle executor. TaskManager
also kept the task-scheduler pool alive only to close transactions on
it.

Remove the masterelection classes other than GlobalMasterInfo, the
HugeGraph.roleElectionStateMachine() accessor, the server.role_election
and server.role.* options, the deprecation warnings added in apache#3082,
and TaskManager's scheduler pool and role callbacks.

Old config files that still set the removed keys only get HugeConfig's
"redundant option" warning. HugeVertex keeps mapping the ~role_data
label to HugeType.SERVER so vertices left in existing graphs still
route to the same table.
ServerInfoManager.init() and heartbeat() have been no-ops since apache#3082,
and tx()/call() had no callers, so the server-info-db-worker pool that
backed them never ran anything. Remove those methods, the executor, the
constructor parameter threaded through the task schedulers, and the
HugeServerInfo vertex class.

ServerInfoManager itself stays: StandardHugeGraph still hands it the
node info, and TaskScheduler.serverManager() is part of the interface.

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

Blocking: no. Summary: Removing the public Java role-election API breaks consumers that depend on that interface method. Add migration guidance or retain a deprecated bridge through the declared removal version. Evidence: The exact-head diff removes roleElectionStateMachine() from HugeGraph.java and deletes its return type.

@byteayan

Copy link
Copy Markdown
Contributor Author

@imbajin I added a "Migration notes (for the release notes)" section to the description covering the removed HugeGraph.roleElectionStateMachine() API, the scheduler constructor changes and the removed config keys. The paired doc PR apache/hugegraph-doc#502 now keeps a 1.7.0 note for these options. PTAL when you have a moment.

@bitflicker64

Copy link
Copy Markdown
Contributor

Checked what merging this does to the other open PRs: I ran git merge-tree of every open PR that touches a file changed here (16 of them) against master + this head, and grepped each for the removed classes, methods and config keys.

Only one gets a new conflict: #3139 adds an import directly below the three masterelection imports this PR deletes from GraphManager.java. It is a one-line import fix on that side, noted there. Nothing needs to change here. The other 15 either merge cleanly or conflict only where they already conflict with master, and none of them uses anything this PR removes.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.58%. Comparing base (2f827d6) to head (5117958).

Files with missing lines Patch % Lines
...ava/org/apache/hugegraph/structure/HugeVertex.java 50.00% 0 Missing and 2 partials ⚠️
...in/java/org/apache/hugegraph/task/TaskManager.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3244      +/-   ##
============================================
+ Coverage     41.40%   41.58%   +0.17%     
+ Complexity     7337     7326      -11     
============================================
  Files           802      795       -7     
  Lines         69792    69198     -594     
  Branches       9312     9269      -43     
============================================
- Hits          28897    28773     -124     
+ Misses        37604    37145     -459     
+ Partials       3291     3280      -11     

☔ 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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Blocking: no. Summary: The removal is complete at 5117958. No removed class, method, option or pool is still referenced, HugeVertex still maps ~server and ~role_data to HugeType.SERVER with the same label strings the deleted classes used, and old configs that set server.role_election, server.role.* or task.scheduler_type still load with a redundant-option warning while server.role keeps applying. The Java API break raised earlier is now covered by the migration notes in the description. Evidence: static review of the full diff against 2f827d6 plus git grep at head for every removed symbol; TaskManager.shutdown() ordering, the HugeFactoryAuthProxy filter lists and HugeConfig.addPropertyDirect checked; no use of the removed API in hugegraph-toolchain, hugegraph-computer or hugegraph-ai; all 22 checks at this head pass, with UnitTestSuite 747/0 failures (memory job) and CoreTestSuite 816/0 plus ApiTestSuite 161/0 (rocksdb job).

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

LGTM

@imbajin imbajin changed the title refactor(server): remove legacy master-worker scheduler code (phase 2) refactor(server): remove legacy scheduler code [p2] Sep 30, 2026
@imbajin
imbajin merged commit 82034fb into apache:master Sep 30, 2026
22 checks passed
byteayan added a commit to byteayan/hugegraph that referenced this pull request Oct 1, 2026
RedirectFilter only forwarded requests when
GlobalMasterInfo.supportElection() was true, and the only code that set
it was the role election path removed in apache#3244, which nothing had
called since apache#3082. The filter was still registered on 21 endpoint
methods and returned early on every request.

Remove RedirectFilter, RedirectFilterDynamicFeature and the
@RedirectMasterRole annotations, the election and master URL state in
GlobalMasterInfo, and GraphTransaction.queryServerInfos(), which read
the ~server vertices HugeServerInfo used to write and had no callers.
imbajin pushed a commit that referenced this pull request Oct 2, 2026
RedirectFilter only forwarded requests when
GlobalMasterInfo.supportElection() was true, and the only code that set
it was the role election path removed in #3244, which nothing had
called since #3082. The filter was still registered on 21 endpoint
methods and returned early on every request.

Remove RedirectFilter, RedirectFilterDynamicFeature and the
@RedirectMasterRole annotations, the election and master URL state in
GlobalMasterInfo, and GraphTransaction.queryServerInfos(), which read
the ~server vertices HugeServerInfo used to write and had no callers.
@byteayan
byteayan deleted the refactor/scheduler-phase2-cleanup branch October 2, 2026 10:04
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.

[TASK] Refactor: phase 2 cleanup — remove legacy master-worker scheduler dead code

3 participants