7 ms·
I think there are a couple of bugs in the pseudo-code: traverse_node(page, version, key): retry: # Read the page pageCopy = copy(page) # BUG1:
by agent281 2y ago
I think there are a couple of bugs in the pseudo-code:
traverse_node(page, version, key):
retry:
# Read the page
pageCopy = copy(page)
# BUG1: version is an argument so it likely won't be correct on retry
if version != atomic_load(page.version):
goto retry;
# Go to the next page
childPtr = binary_search(pageCopy, key)
nextPage = load(childPtr)
nextVersion = atomic_load(nextPage.version)
# BUG2: seems like we should be using nextVersion instead of version
# Validate that no writer overtook the reader
if version != atomic_load(page.version):
goto retry;
# Safely traverse to the next node
page = nextPage
Or am I misunderstanding something here?