Skip to content
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

Merged
merged 4 commits into from
Jul 26, 2016

Conversation

jwilder
Copy link
Contributor

@jwilder jwilder commented Jul 25, 2016

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

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

@jwilder jwilder added this to the 1.0.0 milestone Jul 25, 2016
var inuse bool
for _, f := range files {
if _, ok := c.files[f]; ok {
inuse = true
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@corylanou
Copy link
Contributor

Looks good. Minor nit. Also, could there be tests added to verify this functionality? 👍

jwilder added 4 commits July 26, 2016 12:58
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
@jwilder jwilder merged commit 8e1f238 into master Jul 26, 2016
@jwilder jwilder deleted the jw-compact-full branch July 26, 2016 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants