fix: ensure "local" ObjectStore.list returns ordered elements #26081
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.
While initially attempting to reproduce a data corruption issue in enterprise, I encountered unexpected behavior during compactor restarts -- namely, that the compactor would always load the wrong compaction summary. It should just load the latest compaction summary which would show up as the first item in an object store listing if the object store listed items in UTF-8 binary order (ascending).
This is the case when using the S3-backed object store, but not when using the
LocalFileSystem
.Indeed, the
ObjectStore
trait explicitly doesn't guarantee the order of list results.This PR attempts to address this issue by wrapping the returned
LocalFileSystem
instances with one that collects the inner implementation'slist
operation results into a vec and sorts them before streamin them back to the caller.One downside of this approach is that it will cause a tokio thread to block due to the use of
futures::executor::block_on
, but I don't know of any better way to collect results from the innerLocalFileSystem.list
's returnedBoxStream<...>
value.The reason that's necessary is that
ObjectStore.list
isn't an async function so we can't await it without invoking some kind of async executor.I went with this approach in spite of this downside because...
LocalFileSystem
object object_store.ObjectStore
API would make it easy to miss a case where ordering of the object store list results is important and leave a bug for future developers to come across.--object-store=file
implementation is meant for local dev testing, not production -- I think it's fine to be more relaxed about blocking a tokio thread in this restricted scope.