Skip to content

refactor(server): remove the inactive master redirect filter - #3246

Merged
imbajin merged 1 commit into
apache:masterfrom
byteayan:refactor/remove-redirect-filter
Oct 2, 2026
Merged

imbajin merged 1 commit into
apache:masterfrom
byteayan:refactor/remove-redirect-filter

Conversation

@byteayan

@byteayan byteayan commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of the PR

RedirectFilter forwarded requests to the elected master only when GlobalMasterInfo.supportElection() was true. The only code that set the flag was GraphManager.initRoleStateMachine(), which nothing called after #3082 and which #3244 removed. The filter was still registered on 21 endpoint methods through @RedirectMasterRole and returned early on every request.

Main Changes

  • Delete RedirectFilter, RedirectFilterDynamicFeature, the @RedirectFilter.RedirectMasterRole annotations on the schema, job, task and raft APIs, and the registration in ApplicationConfig.
  • Reduce GlobalMasterInfo to the node id and node role. supportElection, the master NodeInfo, masterInfo(...), resetMasterInfo() and the stale master-worker TODO are gone. GlobalMasterInfo.master(...) stays, since tests, the example and the Gremlin scripts use it.
  • Delete both GraphTransaction.queryServerInfos(...) overloads. They read the ~server vertices that HugeServerInfo used to write and had no callers.
  • Drop AccessLogFilterTest.testRedirectRunsAfterBodyCapture, which only checked the removed filter's registration priority.

HugeType.SERVER and the legacy ~server / ~role_data label mapping in HugeVertex are unchanged.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests: UnitTestSuite (including ServerInfoManagerTest, SecurityManagerTest and AccessLogFilterTest) and the API tests for the endpoints that carried the annotation (EdgeLabelApiTest, IndexLabelApiTest, PropertyKeyApiTest, VertexLabelApiTest, GremlinApiTest, TaskApiTest).
  • Need tests and can be verified as follows:
    • xxx

Ran the full UnitTestSuite locally on JDK 11 (746 run, 0 failures). The API tests, which exercise the annotated endpoints, were left to CI.

Does this PR potentially affect the following parts?

"The public API" here means the Java GlobalMasterInfo and GraphTransaction methods listed above. The REST endpoints respond as before because the redirect never ran. The x-hg-redirect header only told the filter to skip forwarding, so ignoring it changes nothing either.

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:

@bitflicker64

Copy link
Copy Markdown
Contributor

Same check as on #3244, this time against master + this head (which includes #3244).

This commit adds one new conflict: #3144 adds its CompressInterceptor imports next to import org.apache.hugegraph.api.filter.RedirectFilter; in TaskAPI.java. It is an import-only fix on that side (resolved locally, mvn -o compile passes through hugegraph-test), noted there. Nothing needs to change here. #3237 still calls GlobalMasterInfo.master(...), which this PR keeps, and it compiles on top of it. No other open PR picks up a new conflict or a reference to the removed filter or annotations.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.55%. Comparing base (82034fb) to head (456cb36).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3246      +/-   ##
============================================
- Coverage     41.57%   41.55%   -0.02%     
+ Complexity     7325     7305      -20     
============================================
  Files           795      793       -2     
  Lines         69198    69106      -92     
  Branches       9269     9258      -11     
============================================
- Hits          28770    28719      -51     
+ Misses        37145    37108      -37     
+ Partials       3283     3279       -4     

☔ 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 safe. On master (82034fb, which already contains #3244) nothing calls GlobalMasterInfo.supportElection(true), so RedirectFilter.filter() always returned at the !globalNodeInfo.supportElection() check before any forwarding, and dropping the filter, its DynamicFeature, the 21 @RedirectMasterRole annotations and the master NodeInfo state does not change any REST response. GraphTransaction.queryServerInfos(...) has no callers left. Since #3244 was squash-merged and its tree matches master exactly, only 4792aca is new; a rebase will drop the first two commits from the diff. Evidence: static review of 4792aca against 5117958 (git diff 5117958 origin/master is empty). git grep at the head finds no remaining use of RedirectFilter, RedirectMasterRole, supportElection, masterInfo, resetMasterInfo, GlobalMasterInfo.NodeInfo, queryServerInfos or x-hg-redirect, and the local hugegraph-toolchain, hugegraph-computer and hugegraph-ai checkouts do not reference them either. GlobalMasterInfo.master(...), initNodeRole and changeNodeRole keep their behaviour. All 22 checks at this head are green, including build-server on memory, rocksdb and hbase, and the hstore, pd and store jobs.

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

✅ Score: 9.1/10

No blocking regression was found in the removal of the inactive redirect/election path. The retained node-role behavior and in-repository callers were checked.

Resolve or explicitly assess the coverage gate before merging. This cleanup has lower release priority than upgrade and query correctness fixes.

@byteayan

byteayan commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. On codecov/project at 456cb36 (41.55%, -0.02% vs 82034fb): the drop doesn't come from this change. Per Codecov's compare data, the code this PR deletes or edits (RedirectFilter, RedirectFilterDynamicFeature, the election state in GlobalMasterInfo, ApplicationConfig, GraphTransaction.queryServerInfos) removes 92 lines and 30 hits, which on its own would put coverage at 41.59% (+0.01%). The difference is 21 fewer hits in files this PR doesn't touch, mostly timing-dependent PD/Store/HStore code (DistributedTaskScheduler -7, store PartitionManager -6, PdMetaDriver -3, TaskMetaManager -2, several -1s, +2 in TaskScheduleService), so it is run-to-run variation rather than lost coverage. Patch coverage is 100% (codecov/patch passes), and codecov/project is not among the required checks in .asf.yaml. If you'd like the check green before merging, re-running the hstore/pd/store jobs may settle it.

@imbajin
imbajin merged commit 176fb56 into apache:master Oct 2, 2026
21 of 22 checks passed
@byteayan
byteayan deleted the refactor/remove-redirect-filter 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: remove the inactive RedirectFilter master redirect

3 participants