Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Test getAllChildrenPaginated for transaction children deleted case #9

Open
huizhilu opened this issue Dec 15, 2020 · 0 comments
Open
Assignees

Comments

@huizhilu
Copy link

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.

} 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

@huizhilu huizhilu self-assigned this Dec 15, 2020
rahulrane50 pushed a commit to linkedin/zkbridge that referenced this issue Apr 25, 2024
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

No branches or pull requests

1 participant