mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-27 03:45:11 +00:00
Previously it was the responsibility of the layer above (multishard combining reader) to pause readers, which happened via an explicit `pause()` call. This proved to be a very bad design as we kept finding spots where the multishard reader should have paused the reader to avoid potential deadlocks (due to starved reader concurrency semaphores), but didn't. This commit moves the responsibility of pausing the reader into the shard reader. The reader is now kept in a paused state, except when it is actually used (a `fill_buffer()` or `fast_forward_to()` call is executing). This is fully transparent to the layer above. As a side note, the shard reader now also hides when the reader is created. This also used to be the responsibility of the multishard reader, and although it caused no problems so far, it can be considered a leak of internal details. The shard reader now automatically creates the remote reader on the first time it is attempted to be used. The code has been reorganized, such that there is now a clear separation of responsibilities. The multishard combining reader handles the combining of the output of the shard readers, as well as issuing read-aheads. The shard reader handles read-ahead and creating the remote reader when needed, as well as transferring the results of remote reads to the "home" shard. The remote reader (`shard_reader::remote_reader`, new in this patch) handles pausing-resuming as well as recreating the reader after it was evicted. Layers don't access each other's internals (like they used to). After this commit, the reader passed to `destroy_reader()` will always be in paused state.
24 KiB
24 KiB