Skip to content

refactor(server): remove legacy master-worker scheduler code (phase 2) - #3244

Open
byteayan wants to merge 2 commits into
apache:masterfrom
byteayan:refactor/scheduler-phase2-cleanup
Open

byteayan wants to merge 2 commits into
apache:masterfrom
byteayan:refactor/scheduler-phase2-cleanup

Conversation

@byteayan

@byteayan byteayan commented Sep 27, 2026 •

Copy link
Copy Markdown

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. Since refactor(server): disable legacy master-worker scheduler logic #3082 the returned state machine was never started, so there is no behavior to port: delete the call. The task scheduler is picked by backend (DistributedTaskScheduler for hstore, StandardTaskScheduler otherwise), and 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.

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

2 participants