Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign updb: concurrent, overlapping L0→Lbase compactions permitted #875
Comments
|
Running
on master ( c29cc16 ) should reproduce locally. |
I’m kinda surprised that we haven’t hit this before. It looks like two files were moved from L0→L5 concurrently. AFAIK, we don’t have any checks in place to prevent this. We just check to make sure compaction inputs aren’t already compacting, but two L0→Lbase compactions can overlap without sharing any compaction inputs if their intersection does not overlap any tables in Lbase. This Lines 772 to 774 in b66f9d0 |
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 9, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 9, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 9, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 10, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 11, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 11, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
jbowens
added a commit
to jbowens/pebble
that referenced
this issue
Sep 14, 2020
Previously, it was possible for compaction picking to pick an L0->LBase compaction that conflicted with an existing L0->LBase compaction under specific conditions. A flush of a new sstable constructs a new Version and sublevel intervals. If a flushed table does not overlap any individual currently-compacting files, its intervals within sublevels datastructures are not marked as compacting, although the flushed table may still overlap with the active compaction's key range (eg, if the new sstable sits squarely between two compacting files' keyspaces). If no files exist in LBase that intersect with the intersection of the newly flushed sstable's keyspace and the active compaction's keyspace, a new compaction of the flush sstable would be allowed to start. This change augments our existing concurrent compaction failsafe to compare picked L0->LBase compaction key ranges against the key ranges of in-progress compactions, preventing the compaction if necessary. I think we'll probably want to also adapt L0 sublevels to avoid picking these base compactions earlier through passing active compactions into InitCompactingFileInfo, but adding this to the failsafe also patches the non-sublevels codepaths and will provide defense in depth once we fix L0-sublevel picking. Fix cockroachdb#875.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was testing a nightly metamorphic tests TeamCity configuration and it uncovered an invariant violation.
https://teamcity.cockroachdb.com/repository/download/Cockroach_Nightlies_Pebble_Metamorphic/2249146:id/stress.log