Added yield to remap cleanup loop to prevent a stack overflow if too many queue entries are processed without waiting on IO.

This commit is contained in:
Steve Atherton 2020-12-12 02:40:06 -08:00
parent 5f06c20d08
commit d7ebae07f5
1 changed files with 6 additions and 0 deletions

View File

@ -1837,6 +1837,7 @@ public:
state Version minStopVersion = cutoff.version - (BUGGIFY ? deterministicRandom()->randomInt(0, 10) : (self->remapCleanupWindow * SERVER_KNOBS->REDWOOD_REMAP_CLEANUP_LAG));
self->remapDestinationsSimOnly.clear();
state int sinceYield = 0;
loop {
state Optional<RemappedPage> p = wait(self->remapQueue.pop(cutoff));
debug_printf("DWALPager(%s) remapCleanup popped %s\n", self->filename.c_str(), ::toString(p).c_str());
@ -1855,6 +1856,11 @@ public:
if (self->remapCleanupStop && p.get().version >= minStopVersion) {
break;
}
if(++sinceYield >= 100) {
sinceYield = 0;
wait(yield());
}
}
debug_printf("DWALPager(%s) remapCleanup stopped (stop=%d)\n", self->filename.c_str(), self->remapCleanupStop);