mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-18 05:30:37 +00:00
This is preliminary work for/from #4220 (async `Layer::get_value_reconstruct_data`). That plan involves turning Timeline::layers into a `tokio::sync::RwLock`. Before this patch, `compact_level0_phase1` would drop and re-acquire `Timeline::layers` (`read().unwrap()`). We can't have that if we switch to an async RwLock because tokio::sync::RwLock's read guard is `!Send`. Which makes the compaction task future `!Send`. Which doesn't compile because the compaction task runs inside a `task_mgr` task, and `task_mgr` requires the task futures to be `Send`. I think the performance impact of holding the lock for longer will be minimal as the number of L0s should be bounded, and so, any of the prep work that we're doing in the section where we previously didn't hold the lock should be fast anyways. The far worse part of this function in terms of lock contention / performance is the fact that we hold the read lock while we write out the L1s. But that's a pre-existing condition => not changing it here.