reader_concurrency_semaphore: admit one read if no reader is active

To ensure progress at all times. This is due to evictable readers, who
still hold on to a buffer even when their underlying reader is evicted.
As we are introducing buffer and mutation fragment tracking in the next
patches, these readers will hold on to memory even in this state, so it
may theoretically happen that even though no readers are admitted (all
count resources all available) no reader can be admitted due to lack of
memory. To prevent such deadlocks we now always admit one reader if all
count resource are available.
This commit is contained in:
Botond Dénes
2020-09-16 10:14:14 +03:00
parent ef0b279c80
commit 0fe75571d9

View File

@@ -153,7 +153,9 @@ bool reader_concurrency_semaphore::has_available_units(const resources& r) const
}
bool reader_concurrency_semaphore::may_proceed(const resources& r) const {
return has_available_units(r) && _wait_list.empty();
// Special case: when there is no active reader (based on count) admit one
// regardless of availability of memory.
return _wait_list.empty() && (has_available_units(r) || _resources.count == _initial_resources.count);
}
future<reader_permit::resource_units> reader_concurrency_semaphore::do_wait_admission(size_t memory, db::timeout_clock::time_point timeout) {