Flush memtable after timeout since got dirty (1st write) instead of idle (last write) #4335
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.
What's being changed:
Memtable is flushed to segment file when its size exceeds given threshold or time has passed since it is being written to.
Previously idle timeout (time since last write) was used to trigger flush. In case of multiple tenants having little data pushed to memtable very often, both flush conditions (exceeded size or idle timeout) could not be met and a lot of data had to be stored in memory before it was eventually saved to file.
This PR changes flush trigger to dirty timeout (time since first write). That way memtable is flushed even if very little data is written within configured timeframe, preventing data being kept in memory for too long.
Notes:
PERSISTENCE_MEMTABLES_FLUSH_DIRTY_AFTER_SECONDS
replacing existingPERSISTENCE_MEMTABLES_FLUSH_IDLE_AFTER_SECONDS
. If first one is not set, latter one is used as a fallback.PERSISTENCE_MEMTABLES_FLUSH_DIRTY_AFTER_SECONDS
is 60s (same asPERSISTENCE_MEMTABLES_FLUSH_IDLE_AFTER_SECONDS
used to be)Review checklist