reader_concurrency_semaphore: Fix stop() in face of evictable reads becoming inactive #15535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scylla can crash due to a complicated interaction of service level drop, evictable readers, inactive read registration path.
service level drop invoke stop of reader concurrency semaphore, which will wait for in flight requests
turns out it stops first the gate used for closing readers that will become inactive.
proceeds to wait for in-flight reads by closing the reader permit gate.
one of evictable reads take the inactive read registration path, and finds the gate for closing readers closed.
flat mutation reader is destroyed, but finds the underlying reader was not closed gracefully and triggers the abort.
By closing permit gate first, evictable readers becoming inactive will be able to properly close underlying reader, therefore avoiding the crash.
Fixes #15534.