Redwood: Fix clearRemapQueue after the remap cleanup window change

This commit is contained in:
Yi Wu 2022-03-07 22:53:52 -08:00
parent 0968566fd5
commit 66c82ff00d
1 changed files with 13 additions and 6 deletions

View File

@ -3797,16 +3797,23 @@ private:
ACTOR static Future<Void> clearRemapQueue_impl(DWALPager* self) {
// Wait for outstanding commit.
wait(self->commitFuture);
self->setOldestReadableVersion(self->getLastCommittedVersion());
wait(self->commit(self->getLastCommittedVersion() + 1));
wait(self->remapCleanupFuture);
// Set remap cleanup window to 0 to allow the remap queue to drain.
state int64_t remapCleanupWindowBytes = self->remapCleanupWindowBytes;
self->remapCleanupWindowBytes = 0;
// While the remap queue isn't empty, advance the commit version and oldest readable version
// by the remap cleanup window and commit
while (self->remapQueue.numEntries > 0) {
self->setOldestReadableVersion(self->getLastCommittedVersion());
wait(self->commit(self->getLastCommittedVersion() + self->remapCleanupWindowBytes + 1));
self->remapCleanupFuture = remapCleanup(self);
wait(self->remapCleanupFuture);
}
// One final commit because the active commit cycle may have popped from the remap queue
wait(self->commit(self->getLastCommittedVersion() + 1));
// Restore remap cleanup window.
if (remapCleanupWindowBytes != 0)
self->remapCleanupWindowBytes = remapCleanupWindowBytes;
TraceEvent e("RedwoodClearRemapQueue");
self->toTraceEvent(e);