You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@amoro.apache.org by "zhoujinsong (via GitHub)" <gi...@apache.org> on 2026/09/08 08:47:52 UTC
[PR] [Refactor] Decouple HA container and bucket assignment store [amoro]
zhoujinsong opened a new pull request, #4367:
URL: https://github.com/apache/amoro/pull/4367
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://amoro.apache.org/how-to-contribute/
2. If the PR is related to an issue in https://github.com/apache/amoro/issues, add '[AMORO-XXXX]' in your PR title, e.g., '[AMORO-XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][AMORO-XXXX] Your PR title ...'.
-->
## Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about its use case.
2. If you fix a bug, you can clarify why it is a bug.
3. Use Fix/Resolve/Close #{ISSUE_NUMBER} to link this PR to its related issue
-->
This is a follow-up PR after #4339.
This PR tried to decouple the HA container and bucket assignment store.
## Brief change log
<!--
Clearly describe the changes made in modules, classes, methods, etc.
-->
- As title
## How was this patch tested?
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] Run test locally before making a pull request
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Refactor] Decouple HA container and bucket assignment store [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #4367: [Refactor] Decouple HA container and bucket assignment store
URL: https://github.com/apache/amoro/pull/4367
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Refactor] Decouple HA container and bucket assignment store [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #4367:
URL: https://github.com/apache/amoro/pull/4367#issuecomment-6329371602
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Refactor] Decouple HA container and bucket assignment store [amoro]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #4367:
URL: https://github.com/apache/amoro/pull/4367#issuecomment-6181245082
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@amoro.apache.org list. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Refactor] Decouple HA container and bucket assignment store [amoro]
Posted by "xxubai (via GitHub) via commits" <co...@amoro.apache.org>.
xxubai commented on code in PR #4367:
URL: https://github.com/apache/amoro/pull/4367#discussion_r4550585445
##########
amoro-ams/src/main/java/org/apache/amoro/server/ZkBucketAssignStore.java:
##########
@@ -199,6 +199,35 @@ public List<AmsServerInfo> getAliveNodes() throws BucketAssignStoreException {
return nodes;
}
+ @Override
+ public void registerNode(AmsServerInfo serverInfo) throws BucketAssignStoreException {
+ String nodeKey = getNodeKey(serverInfo);
+ String nodePath = assignmentsBasePath + "/" + nodeKey;
+ String serverInfoJson = JacksonUtil.toJSONString(serverInfo);
+ try {
+ zkClient
+ .create()
+ .creatingParentsIfNeeded()
+ .withMode(CreateMode.EPHEMERAL)
Review Comment:
**[P1] Separate ephemeral membership from assignment storage.** On a fresh cluster, this makes `/bucket-assignments/{nodeKey}` ephemeral, but `saveAssignments()` and `updateLastUpdateTime()` create children beneath it. ZooKeeper rejects those writes with `NoChildrenForEphemeralsException`, so the node never receives buckets. Please use a separate ephemeral registration path and cover registration followed by assignment with a real ZooKeeper test.
##########
amoro-ams/src/main/java/org/apache/amoro/server/DBBucketAssignStore.java:
##########
@@ -118,6 +118,44 @@ public void removeAssignments(AmsServerInfo nodeInfo) throws BucketAssignStoreEx
}
}
+ @Override
+ public void registerNode(AmsServerInfo serverInfo) throws BucketAssignStoreException {
+ String nodeKey = getNodeKey(serverInfo);
+ String serverInfoJson = JacksonUtil.toJSONString(serverInfo);
+ long now = System.currentTimeMillis();
+ try {
+ int updated =
+ updateAs(
+ BucketAssignMapper.class,
+ mapper -> mapper.updateNodeHeartbeat(clusterName, nodeKey, now))
+ .intValue();
+ if (updated == 0) {
+ doAs(
+ BucketAssignMapper.class,
+ mapper ->
+ mapper.insert(
Review Comment:
**[P2] Tolerate concurrent heartbeat inserts during registration.** The HA heartbeat already starts in the container constructor. If it inserts this node after the registration UPDATE returns zero, this INSERT fails with a duplicate key. The exception propagates through `startBaseServices()` and causes AMS to exit. Please use an atomic upsert or retry the update on duplicate insertion; this interleaving is reproducible with Derby.
##########
amoro-ams/src/main/java/org/apache/amoro/server/AmsAssignService.java:
##########
@@ -132,12 +113,7 @@ public void stop() {
@VisibleForTesting
public void doAssign() {
try {
- if (!haContainer.hasLeadership()) {
- LOG.debug("Current node is not leader, skip bucket assignment");
- return;
- }
-
- List<AmsServerInfo> aliveNodes = haContainer.getAliveNodes();
+ List<AmsServerInfo> aliveNodes = assignStore.getAliveNodes();
Review Comment:
**[P1] Exclude persistent assignment directories from live membership.** The ZK store's `getAliveNodes()` scans assignment directories, which are persistent in the previous implementation. During upgrade, `registerNode()` only updates their data on `NodeExists`; they remain persistent. After a node crashes, it is still reported as alive and its buckets are not reassigned on failure. Please discover membership from a separate ephemeral path and add an upgrade/failure regression test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Refactor] Decouple HA container and bucket assignment store [amoro]
Posted by "xxubai (via GitHub) via commits" <co...@amoro.apache.org>.
xxubai commented on code in PR #4367:
URL: https://github.com/apache/amoro/pull/4367#discussion_r4610694803
##########
amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java:
##########
@@ -341,6 +338,27 @@ public void stopLeaderServices() {
haState = HAState.FOLLOWER;
}
+ public void stopBaseServices() {
+ disposeRestService();
+ if (IS_MASTER_SLAVE_MODE) {
+ if (bucketAssignStore != null && haContainer != null) {
+ try {
+ bucketAssignStore.removeNode(haContainer.getOptimizingServiceServerInfo());
Review Comment:
**[P1] Retain departed assignments until their buckets are reclaimed.** Both stores' `removeNode()` delete the assignments along with membership. With two nodes holding 50 buckets each, stopping one leaves only the survivor's 50 buckets in the store. `doAssign()` sees no node changes, treats the single survivor as balanced, and never reassigns the missing 50 buckets. Please defer assignment deletion to the assigner or check total bucket coverage on every pass. Reproduced with Derby across 10 assignment cycles.
##########
amoro-ams/src/main/java/org/apache/amoro/server/ZkBucketAssignStore.java:
##########
@@ -174,10 +184,10 @@ public Map<AmsServerInfo, List<String>> getAllAssignments() throws BucketAssignS
public List<AmsServerInfo> getAliveNodes() throws BucketAssignStoreException {
List<AmsServerInfo> nodes = new ArrayList<>();
try {
- if (zkClient.checkExists().forPath(assignmentsBasePath) == null) {
+ if (zkClient.checkExists().forPath(nodesBasePath) == null) {
return nodes;
}
- List<String> nodeKeys = zkClient.getChildren().forPath(assignmentsBasePath);
+ List<String> nodeKeys = zkClient.getChildren().forPath(nodesBasePath);
Review Comment:
**[P2] Preserve discovery of legacy registrations during upgrades.** Before this PR, live nodes register as `/nodes/node-000...` with their server info in the JSON payload. This loop now expects every child name to be `host:port`, so it excludes all old-version nodes. During a rolling upgrade, a new leader can reclaim buckets from nodes that are still running. Please read the registration payload for both layouts and add a mixed-version membership test.
##########
amoro-ams/src/main/java/org/apache/amoro/server/ZkBucketAssignStore.java:
##########
@@ -199,6 +209,52 @@ public List<AmsServerInfo> getAliveNodes() throws BucketAssignStoreException {
return nodes;
}
+ @Override
+ public void registerNode(AmsServerInfo serverInfo) throws BucketAssignStoreException {
+ String nodeKey = getNodeKey(serverInfo);
+ // Register in the dedicated ephemeral membership path, NOT under the bucket-assignments
+ // path. Ephemeral nodes cannot have children in ZooKeeper, and assignments are stored as
+ // children of the per-node path, so registration must live in a separate path.
+ String nodePath = nodesBasePath + "/" + nodeKey;
+ String serverInfoJson = JacksonUtil.toJSONString(serverInfo);
+ try {
+ zkClient
+ .create()
+ .creatingParentsIfNeeded()
+ .withMode(CreateMode.EPHEMERAL)
+ .forPath(nodePath, serverInfoJson.getBytes(StandardCharsets.UTF_8));
+ LOG.debug("Registered node {} in ZK", nodeKey);
+ } catch (KeeperException.NodeExistsException e) {
+ // Already registered, update data
+ try {
+ zkClient.setData().forPath(nodePath, serverInfoJson.getBytes(StandardCharsets.UTF_8));
Review Comment:
**[P1] Ensure registration belongs to the new session after a fast restart.** If the previous process's session has not expired, this fixed path still belongs to that session. `setData()` does not transfer ephemeral ownership, so the old session's eventual expiry deletes the restarted process's registration while its new connection remains healthy. There is no subsequent registration attempt. Please handle an existing node owned by another session; the new restart test currently deletes it manually before registering, bypassing this case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@amoro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org