Repository navigation
[Refactor] Decouple HA container and bucket assignment store - #4367
zhoujinsong wants to merge 13 commits into
Conversation
|
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 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. |
xxubai
left a comment
There was a problem hiding this comment.
Requesting changes for the three reproducible issues below. The 35 existing targeted tests pass, but do not cover these scenarios.
ZkBucketAssignStore:
- registerNode() now creates the ephemeral registration under the dedicated
nodes path (/{ns}/amoro/ams/nodes/{nodeKey}) instead of under
/bucket-assignments/{nodeKey}. ZooKeeper rejects children of ephemeral
nodes (NoChildrenForEphemeralsException), so the previous layout broke
saveAssignments()/updateLastUpdateTime() on a fresh cluster.
- getAliveNodes() discovers membership from the nodes path; persistent
assignment directories from the old layout are no longer misreported as
alive after a node crash, so its buckets can be reassigned.
- removeNode() clears both the ephemeral registration and the persistent
assignments.
DBBucketAssignStore:
- registerNode() tolerates a concurrent heartbeat insert: if the HA
container's upsertNodeHeartbeat() inserts the row after registration's
UPDATE returns zero, the duplicate-key INSERT is retried as an UPDATE
instead of propagating out of startBaseServices() and killing AMS.
Tests:
- Add TestZkBucketAssignStoreWithRealZk: real-ZooKeeper integration tests
(curator-test TestingServer) covering registration followed by
assignment on a fresh cluster, path separation, crash/upgrade/fast-restart
regressions.
- Add TestDBBucketAssignStore#testRegisterNodeToleratesConcurrentHeartbeatInsert
on Derby for the concurrent duplicate-insert interleaving.
| if (IS_MASTER_SLAVE_MODE) { | ||
| if (bucketAssignStore != null && haContainer != null) { | ||
| try { | ||
| bucketAssignStore.removeNode(haContainer.getOptimizingServiceServerInfo()); |
There was a problem hiding this 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.
| } catch (KeeperException.NodeExistsException e) { | ||
| // Already registered, update data | ||
| try { | ||
| zkClient.setData().forPath(nodePath, serverInfoJson.getBytes(StandardCharsets.UTF_8)); |
There was a problem hiding this 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.
| return nodes; | ||
| } | ||
| List<String> nodeKeys = zkClient.getChildren().forPath(assignmentsBasePath); | ||
| List<String> nodeKeys = zkClient.getChildren().forPath(nodesBasePath); |
There was a problem hiding this 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.
Why are the changes needed?
This is a follow-up PR after #4339.
This PR tried to decouple the HA container and bucket assignment store.
Brief change log
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
Run test locally before making a pull request
Documentation