-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Prevent full compactions from conflicting with other compactions #7055
Conversation
var inuse bool | ||
for _, f := range files { | ||
if _, ok := c.files[f]; ok { | ||
inuse = true |
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.
Could you just return false from here instead of breaking and then checking and returning?
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.
You also wouldn't need the inuse
variable either.
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 was going to say the same, but I wasn't sure if this was more idiomatic.
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.
Yeah. I'll rework. I had a different approach initially and this is leftover from that.
Looks good. Minor nit. Also, could there be tests added to verify this functionality? 👍 |
Using os.O_EXCL is safer than checking and then creating the file.
This causes full compactions to not run if the server is running, but after a restart they do run.
Normally, compactions do not conflict on the files they are compacting. If the full cold threshold is set very low, it can cause conflicts where two compactions compact the same files. The full compaction was the only place this could happen as it's planning is greedy. To make this safer for concurrent execution, the compaction tracks which files are current being compacted and prevents any new compactions from starting if the file set overlaps. Fixes #6595
Required for all non-trivial PRs
Normally, compactions do not conflict on the files they are compacting.
If the full cold threshold is set very low, it can cause conflicts where
two compactions compact the same files. The full compaction was the
only place this could happen as it's planning is greedy and normally does
not run until the shard is cold for a long period of time.
To make this safer for concurrent execution, the compactor tracks which
files are currently being compacted and prevents any new compactions from
starting if the file set overlaps.
Fixes #6595