forked from apache/zookeeper
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Description
There is a retry logic for API getAllChildrenPaginated() when there is deletion in the transaction children(children created by a multi transaction operation) and the new page's start minCzxidOffset shifts. Current implementation uses the last child as a flag to represent if there is offset shifting.
zookeeper/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
Lines 2899 to 2918 in 4ca8b70
| } else { | |
| // If a child with the same czxid is returned in the previous page, and then deleted | |
| // on the server, the children not in the previous page but offset is less than czxidOffset | |
| // would be missed in the next page. Use the last child in the previous page to determine whether or not | |
| // the deletion case happens. If it happens, retry fetching the page starting from offset 0. | |
| String lastChild = childrenPage.isEmpty() ? "" : childrenPage.get(childrenPage.size() - 1); | |
| childrenPage = getChildren(path, watcher, Integer.MAX_VALUE, minCzxid, | |
| nextPage.getMinCzxidOffset() - 1, null, nextPage); | |
| if (!lastChild.equals(childrenPage.get(0))) { | |
| if (retryCount++ >= 5) { | |
| LOG.warn("Failed to fetch children pages because of znode deletion and retries exceeding 5"); | |
| throw KeeperException.create(Code.OPERATIONTIMEOUT); | |
| } | |
| LOG.info("Due to znode deletion, retry fetching children from offset 0 for minCzxid={}, retries={}", | |
| minCzxid, retryCount); | |
| childrenPage = getChildren(path, watcher, Integer.MAX_VALUE, minCzxid, 0, null, nextPage); | |
| } | |
| } | |
| allChildrenSet.addAll(childrenPage); | |
| } while (nextPage.getMinCzxid() != ZooDefs.GetChildrenPaginated.lastPageMinCzxid); |
We want to add a unit test for the code logic. As we could not simulate the read/write race condition on the server, we will need to mock the states in the zookeeper api for the uni test.
Related to #8
Metadata
Metadata
Assignees
Labels
No labels