-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dbnode] Avoid loading blocks in memory for namespaces with snapshots disabled during bootstrapping #3919
Conversation
…e` for second target data and index ranges if bootstrapping namespace is read only. Because of this change, bootstrappers won't keep second range blocks in memory for read only namespaces (`shouldPersist` will evaluate to true for them).
// If yes, return an error to force a retry | ||
if persistConf := ns.DataRunOptions.RunOptions.PersistConfig(); persistConf.Enabled && | ||
persistConf.FileSetType == persist.FileSetSnapshotType { | ||
if runIndex == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think checking for the second run should be enough here to replace previous condition. This is needed because now second run blocks won't always have persist.FileSetSnapshotType
set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that this is not really required to avoid loading blocks in memory for read only? Can we split this into separate PR? Mainly because with my limited knowledge this seem to be a dangerious change that might also affect non read only namespaces and we might need to revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because if this condition is left unchanged, we won't be able to check if target ranges have advanced for read-only namespaces. Don't think that this change is dangerous, because it will behave in the same way as before (just the condition is different)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, i agree the logic is still similar but i agree - i’d rather not change setting file snapshot type to something other than Snapshot.
I’ll keep reviewing and give recommendation once understanding the larger change, but seems we are going from type safe to type unsafe potentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this make more sense if we based the decision on "snapshotEnabled": false
namespace property (instead of readOnly
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that decision based on "snapshotEnabled": false
could be considered as well.
And for Rob's concerns - I don't think type safety gives us much here. The most important thing we're doing here is checking that target ranges have not advanced for the last run or latest ranges we've calculated before. I am not sure if this should depend on snapshot fileSet type because this is more of the time problem we're solving here and not the type of persistence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated PR to use snapshotEnabled
instead.
Codecov Report
@@ Coverage Diff @@
## master #3919 +/- ##
========================================
- Coverage 56.9% 56.6% -0.4%
========================================
Files 555 555
Lines 63456 63326 -130
========================================
- Hits 36152 35882 -270
- Misses 24119 24240 +121
- Partials 3185 3204 +19
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
// If yes, return an error to force a retry | ||
if persistConf := ns.DataRunOptions.RunOptions.PersistConfig(); persistConf.Enabled && | ||
persistConf.FileSetType == persist.FileSetSnapshotType { | ||
if runIndex == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that this is not really required to avoid loading blocks in memory for read only? Can we split this into separate PR? Mainly because with my limited knowledge this seem to be a dangerious change that might also affect non read only namespaces and we might need to revert it.
@@ -215,23 +219,24 @@ func (b bootstrapProcess) Run( | |||
}, | |||
}) | |||
secondRanges := b.newShardTimeRanges( | |||
dataRanges.secondRangeWithPersistFalse.Range, namespace.Shards) | |||
dataRanges.secondRange.Range, namespace.Shards) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm why are we using “secondRange” instead of “secondRangeWithPersistFalse” here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because if namespace is read-only, it will resolve to shouldPersist=true
for the second range. Other namespaces will still resolve to shouldPersist=false
as it was before these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just asked for some alignments with the recent readOnly
-> !snapshotEnabled
change (comments inline).
* master: [agg] Use timestamp (not start aligned) for expiring forward versions (#3922) [tests] Add support for calls to label APIs in resources.Coordinator (#3916) [tests] Convert repair_and_replication Docker Integration Test to In-process (#3903) Always Close the conn if failed to write acks (#3855) [m3msg] Add receive and handle latency to consumers (#3920)
Use
persist.FileSetFlushType
instead ofpersist.FileSetSnapshotType
for second target data and index ranges if bootstrapping namespace has!snapshotEnabled
. Because of this change, bootstrappers won't keep their second range blocks in memory for snapshot disabled namespaces (shouldPersist
will evaluate totrue
for them).This should help to reduce dbnode's memory usage during bootstrapping because snapshot-disabled namespaces usually have long retentions and block sizes so keeping them all in memory could potentially lead to OOM.
What this PR does / why we need it:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing and/or backwards incompatible change?:
Does this PR require updating code package or user-facing documentation?: