(2.12) Filestore async flush #7018
Open
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.
The filestore's
AsyncFlush
setting can now be enabled for a JetStream stream using theAllowAsyncFlush
field. Some initial benchmarks showed a 10-15% performance increase when using a R3 stream (3-node cluster with each node in a different availability zone).Only enabling the filestore's
AsyncFlush
setting without additional code would be unsafe. That's why this PR introduces some new mechanisms to track async writes, and only allow the data from the log to be compacted once it has hit JetStream's store. This makes the performance improvement essentially "free", with no negative consequences for data safety/consistency.ApplyWritePending
to track any pending writes done by the filestore.ApplyWritePersisted
is called when the write is actually persisted on disk. This allows async flushing of data, while still informing the Raft code which data it can safely compact. (This also requires passing the index of the append entry down into the filestore, so it can call back up with that index once the relevant data is persisted)AllowAsyncFlush
stream setting can be freely/safely enabled and disabled. It will only be effective when using file storage, and only when the stream is backed by a Raft log, i.e. it's replicated.Relates to #6784
Signed-off-by: Maurice van Veen [email protected]