Skip to content

[Hotfix][AMS] Fix optimizer registration failure under database HA mode - #4352

Open
wangxianghu wants to merge 1 commit into
apache:masterfrom
wangxianghu:hotfix-db-ha
Open

[Hotfix][AMS] Fix optimizer registration failure under database HA mode#4352
wangxianghu wants to merge 1 commit into
apache:masterfrom
wangxianghu:hotfix-db-ha

Conversation

@wangxianghu

Copy link
Copy Markdown

Why are the changes needed?

When HA is enabled with ha.type=database, AmsUtil.getAMSThriftAddress still takes the ZooKeeper branch because it only checks ha.enabled. This makes it build a zookeeper://... address from ha.zookeeper-address, which is not configured in database-HA deployments. The bad URI is injected into the optimizer as ams.optimizer.uri, so the optimizer cannot reach AMS and fails to register.

The fix narrows the ZooKeeper branch to ha.enabled && ha.type == zk. For database HA (and non-HA), it now returns the direct thrift://: address, which is the same host/port the AMS node registers under its lease, so the optimizer registers correctly.

Brief change log

  • AmsUtil.getAMSThriftAddress: only return the ZooKeeper address when ha.enabled is true and ha.type is zk; otherwise fall back to the direct thrift host:port address. This fixes optimizer registration under database-based HA.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible
    • Added TestAmsUtil#getAMSThriftAddress covering: HA disabled, ZK-HA (returns zookeeper://...), and database-HA (falls back to thrift://...).
  • Add screenshots for manual tests if appropriate
  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@github-actions github-actions Bot added the module:ams-server Ams server module label Sep 2, 2026
@wangxianghu

Copy link
Copy Markdown
Author

hi @zhoujinsong could you please take a look when free ? this is simple bug fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ams-server Ams server module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant