[TASK] Refactor: phase 2 cleanup — remove legacy master-worker scheduler dead code
Background
PR #3082 soft-disabled the pre-PD master-worker scheduling path and intentionally left
deprecated config handling, role-election wiring, and ServerInfoManager persistence as
compatibility scaffolding. This issue tracks the follow-up physical removal ("phase 2")
called out in the merge comment ("TODO: cleanup legacy code/configs in phrase2").
Scope of removal
1. Deprecated config warnings + transition tests (low risk)
task.scheduler_typewarning block inStandardHugeGraphENABLE_SERVER_ROLE_ELECTIONwarning inGraphManager.initNodeRole()ServerOptions.ENABLE_SERVER_ROLE_ELECTIONconfig key declaration- Transition-only tests:
testOpenGraphWithDeprecatedTaskSchedulerTypeand
testGraphManagerWarnsOnRoleElection
2. Role election infrastructure (medium risk — touches HugeGraph interface)
All of the following are dead code — nothing starts the state machine after #3082:
StandardHugeGraph.initRoleStateMachine(Id)and theroleElectionStateMachinefieldroleElectionStateMachine()from theHugeGraphinterface andHugeGraphAuthProxyGraphManager.initRoleStateMachine()andGraphManager.supportRoleElection()(never called)StandardRoleListenerclass (never instantiated)TaskManager.onAsRoleMaster()/onAsRoleWorker()no-opsTaskManager.schedulerExecutor(task-scheduler-%d) zombie thread pool andcloseSchedulerTx()RoleElectionOptionsconfig key declarations
3. ServerInfoManager dead persistence path + HugeServerInfo deletion (medium risk)
ServerInfoManager.init()(no-op),heartbeat()(no-op),tx(),call(), and the
dbExecutorfield — the live methods (selfNodeId,selfIsMaster,initServerInfo, etc.)
must be kept sinceDistributedTaskSchedulerstill uses themHugeServerInfo.java— entire class, including~serververtex schema and load trackingserverInfoDbExecutorthread pool andSERVER_INFO_DB_WORKERconstant fromTaskManagerserverInfoDbExecutorparameter fromStandardTaskScheduler,TaskAndResultScheduler,
andDistributedTaskSchedulerconstructors- Update
ServerInfoManagerTestandTaskSchedulerServerInfoTestaccordingly
Suggested PR split
| PR | Scope | Risk |
|---|---|---|
| PR A | Deprecated config warnings + transition tests | Low |
| PR B | Role election infrastructure | Medium |
| PR C | ServerInfoManager surgery + HugeServerInfo deletion |
Medium |
Important constraints
ServerInfoManageritself is not deleted —DistributedTaskSchedulerstill uses
selfNodeId()for task lock scoping.TaskScheduler.serverManager()interface method stays for the same reason.StandardHugeGraph.serverStarted()must keep theinitServerInfo(nodeInfo)call —
only theinitRoleStateMachine(nodeInfo.nodeId())call is removed.- Before deleting
HugeServerInfo, auditHugeVertex.javaforfromVertexdispatch
references and anyinitSchemaIfNeeded()call sites in system init.
Related
- #3082
Implementation Plan
Splitting into 3 PRs ordered by risk. Each PR is independently reviewable and mergeable.
PR A — Remove deprecated config warnings + transition tests
Files to change:
-
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java- Delete the
task.scheduler_typecontainsKeywarning block (~lines 229-234)
- Delete the
-
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java- In
initNodeRole(): remove theenableRoleElectionlocal variable and theif (enableRoleElection)warning block; keep only theSERVER_ROLEread andinitNodeRole()call
- In
-
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/config/ServerOptions.java- Delete the
ENABLE_SERVER_ROLE_ELECTIONconfig key declaration
- Delete the
-
hugegraph-server/hugegraph-test/.../core/MultiGraphsTest.java- Delete
testOpenGraphWithDeprecatedTaskSchedulerType
- Delete
-
hugegraph-server/hugegraph-test/.../unit/core/TaskSchedulerServerInfoTest.java- Delete
testGraphManagerWarnsOnRoleElection
- Delete
No interface changes. Compile + existing tests should pass as-is.
PR B — Remove role election infrastructure
Files to change:
-
StandardHugeGraph.java- In
serverStarted(): remove thethis.initRoleStateMachine(nodeInfo.nodeId())call (keepinitServerInfo) - Delete the entire
initRoleStateMachine(Id serverId)private method - Delete the
roleElectionStateMachinefield declaration - Delete the
roleElectionStateMachine()public method
- In
-
HugeGraph.java(interface)- Remove the
roleElectionStateMachine()method declaration
- Remove the
-
HugeGraphAuthProxy.java- Remove the
roleElectionStateMachine()override and its delegate call
- Remove the
-
GraphManager.java- Delete
initRoleStateMachine()method entirely (never called) - Delete
supportRoleElection()method entirely (never called) - In
serverStarted(): delete the deadif (!this.globalNodeRoleInfo.nodeRole().computer() && ...)block
- Delete
-
TaskManager.java- Delete
onAsRoleMaster()andonAsRoleWorker()no-op methods - Delete
schedulerExecutorfield andTASK_SCHEDULERconstant - Delete
schedulerExecutorallocation in constructor - Delete
closeSchedulerTx()private method - Remove
closeSchedulerTx(graph)call insidecloseScheduler() - Delete
schedulerExecutorshutdown block inshutdown()
- Delete
-
StandardRoleListener.java— delete entire file -
RoleElectionOptions.java— remove all config key declarations (or delete the class if nothing else references it; grep first)
Verify: HugeGraph interface has multiple implementations — make sure all of them compile after removing roleElectionStateMachine().
PR C — Slim ServerInfoManager, delete HugeServerInfo, drop serverInfoDbExecutor
Important constraint: ServerInfoManager is NOT deleted. DistributedTaskScheduler still uses selfNodeId() and selfIsMaster(). The serverManager() method on the TaskScheduler interface stays.
Files to change:
-
ServerInfoManager.java- Remove
dbExecutorfield - Remove
dbExecutorparameter from constructor (and itsE.checkNotNullguard) - Delete
init()method - Delete
heartbeat()method - Delete
tx()private method - Delete
call()private method - Remove dead imports (
Callable,ExecutorService,GraphTransaction,HugeException) close()stays but simplify to justthis.closed = true
- Remove
-
StandardTaskScheduler.java- Remove
serverInfoDbExecutorparameter from constructor - Change
new ServerInfoManager(graph, serverInfoDbExecutor)→new ServerInfoManager(graph) - If
synchronized (this.serverManager)is used as a monitor intx(), replace withsynchronized (this)or a dedicated lock field
- Remove
-
TaskAndResultScheduler.java- Remove
serverInfoDbExecutorparameter from constructor - Change
new ServerInfoManager(graph, serverInfoDbExecutor)→new ServerInfoManager(graph)
- Remove
-
DistributedTaskScheduler.java- Remove
serverInfoDbExecutorparameter from constructor - Update
super(graph, serverInfoDbExecutor)→super(graph)
- Remove
-
TaskManager.java- Delete
serverInfoDbExecutorfield andSERVER_INFO_DB_WORKERconstant - Delete
serverInfoDbExecutorallocation in constructor - Remove
serverInfoDbExecutorargument from bothaddScheduler()constructor calls - Delete
serverInfoDbExecutorshutdown block inshutdown()
- Delete
-
HugeVertex.java- Audit for
HugeServerInforeferences (2 matches) — likely afromVertexdispatch case; remove it
- Audit for
-
StandardHugeGraph.java- Audit for
initSchemaIfNeeded()call onHugeServerInfo.SchemaininitSystemInfo()— remove it
- Audit for
-
HugeServerInfo.java— delete entire file (after removing all call sites above) -
ServerInfoManagerTest.java- Delete
testInitDoesNotAccessBackendStore(method no longer exists) - Update constructor calls: remove the
executorargument everywhere
- Delete
-
TaskSchedulerServerInfoTest.java- Remove
serverInfoDbExecutorlocal variable, itsshutdownNow()call, and the constructor argument from the remaining tests
- Remove
-
TaskAndResultSchedulerTest.java- Same: remove
serverInfoDbExecutorfrom all constructor calls (~10 occurrences)
- Same: remove
Checklist before each PR merges
- [ ]
mvn compilepasses - [ ]
mvn test -pl hugegraph-server/hugegraph-testpasses - [ ] No remaining references to deleted classes/methods (grep for
HugeServerInfo,roleElectionStateMachine,schedulerExecutor,serverInfoDbExecutoras appropriate)
#3244 has been merged as 82034fb, which completes the phase 2 cleanup tracked here. It did not close this issue automatically, so could a maintainer close it? The remaining RedirectFilter dead code is tracked separately in #3245 (fix in #3246).