Skip to content
Snippets Groups Projects
Commit d40d611d authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Konstantin Osipov
Browse files

vinyl: pin run slice in iterator

Currently, we take a reference to vy_slice while waiting for IO in run
iterator to avoid use-after-free. Since a slice references a run, we
also need a reference counter in vy_run. We can't use the same reference
counter for counting the number of active slices, because it includes
deleted slices which stay allocated only because of being pinned by
iterators, hence on top of that we add vy_run->slice_count. And all this
machinery exists solely for the sake of run iterator!

This patch reworks this as follows. It removes vy_run->refs and
vy_slice->refs, leaving only vy_run->slice_count since it is needed for
detecting unused runs. Instead it adds vy_slice->pin_count similar to
vy_mem->pin_count. As long as the pin_count > 0, the slice can't be
deleted. The one who wants to delete the slice (compaction, split, index
removal) has to wait until the slice is unpinned. Run iterator pins the
slice while waiting for IO. All in all this should make the code easier
to follow.
parent 4b5c6d2b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment