[
https://issues.apache.org/jira/browse/CASSANDRA-21842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
koo updated CASSANDRA-21842:
----------------------------
Description:
h3. Description
UCS does not select a single SSTable for tombstone compaction when the file
contains both live data and removable tombstones, and no normal compaction
candidate exists.
LCS handles this case through single-SSTable tombstone compaction. Without this
path, UCS may keep removable tombstones when no new data arrives.
h3. Steps to reproduce
Use a new, empty table for each case. The results below are from a controlled
local storage-engine test.
1. Create a table with PRIMARY KEY (shard, task) and a text value column.
2. Use UCS with scaling_parameters=T4, gc_grace_seconds=0, and
tombstone_compaction_interval=0. Disable automatic compaction while preparing
the data.
3. In each of 32 partitions, insert 16 rows at task keys 0, 3, 6, ..., using
timestamp 100.
4. Delete each range from task to task + 1, using timestamp 200.
5. Insert one live row per partition at task key 100000, using timestamp 300.
6. Flush once to create one SSTable containing live rows and range
tombstones.
7. Once the tombstones are old enough to remove, check whether the strategy
selects a background compaction task. Execute it if selected.
8. Repeat with LCS and with both values of unchecked_tombstone_compaction.
These settings are for an isolated test only.
h3. Actual result
| Case | Task selected | Range tombstone markers before -> after |
| --- | --- | --- |
| UCS T4, one mixed file, unchecked=false | No | 1,024 -> 1,024 |
| UCS T4, one mixed file, unchecked=true | No | 1,024 -> 1,024 |
| UCS L10, one mixed file, unchecked=true | No | 1,024 -> 1,024 |
| LCS, one mixed file, unchecked=false | Yes, tombstone compaction | 1,024 -> 0
|
| LCS, one mixed file, unchecked=true | Yes, tombstone compaction | 1,024 -> 0 |
All 32 live rows remain. The marker count represents the start and end
boundaries of 512 range tombstones.
There are no older external SSTables in this test. UCS also removes tombstones
successfully when normal compaction is triggered with four overlapping files.
h3. Proposed change
Add an optional single-SSTable tombstone compaction path to UCS when no normal
compaction or whole-file expiration task is selected.
Reuse the existing LCS checks and settings:
- tombstone_threshold
- tombstone_compaction_interval
- unchecked_tombstone_compaction
Keep the existing tombstone removal safety checks unchanged.
was:
h3. Description
UCS can keep an SSTable with live data and old tombstones when there are no
normal compaction candidates.
Some tombstones may already be safe to remove, but UCS does not select this
file for a single-SSTable tombstone compaction.
LCS has a path for this case. When there is no normal compaction candidate, it
can select one SSTable based on the estimated droppable tombstone ratio and the
existing eligibility checks.
I propose adding an optional path to UCS that uses the same tombstone
eligibility checks and existing options as LCS. The proposal does not add a
second set of threshold or interval settings.
This is a gap in task selection. UCS can already remove tombstones during
normal compaction, and it can drop fully expired SSTables when it is safe to do
so.
h3. Why this matters
If no new files arrive, normal compaction may not select the remaining mixed
SSTable. Safe-to-remove tombstones can then stay on disk and may add work to
reads.
h3. Steps to reproduce
Use a test environment and a new, empty table for each case. These steps do not
require the local test code.
1. Create a table with columns `shard int`, `task int`, and `value text`, using
`PRIMARY KEY (shard, task)`.
2. Use UCS with the settings below. Set the table's `gc_grace_seconds` to `0`.
Keep automatic compaction disabled while preparing the data.
3. For each of 32 partitions, insert 16 rows with timestamp 100. Place the task
keys three positions apart: 0, 3, 6, and so on.
4. Delete each small range from `task` to `task + 1`, using timestamp 200.
5. Insert one live row in each partition at task key 100000, using timestamp
300. This row is outside the deleted ranges.
6. Flush the table once. Check that the table has one SSTable and that 32 live
rows are still readable. Do not write more data after this step.
7. Wait until the deletion time is older than the GC cutoff and the one-second
whole-file expiry-check interval has passed. Enable automatic compaction for
the table.
8. Observe compaction activity over several background checks. Check whether
the mixed SSTable is rewritten to remove its range tombstones, while keeping
the 32 live rows. A completed check with no selected task is the behavior of
interest; a lack of activity by itself is not proof that a check ran.
9. Repeat from a new, empty table with `unchecked_tombstone_compaction=true`.
10. Repeat the same setup with LCS, leaving out `scaling_parameters`,
`base_shard_count`, `min_sstable_size`, and
`expired_sstable_check_frequency_seconds`. Test both values of
`unchecked_tombstone_compaction`.
h3. Actual result
|Case|Task selected|Range tombstone markers before -> after|
|—|—|—|
|UCS T4, one mixed file, unchecked=false|No|1,024 -> 1,024|
|UCS T4, one mixed file, unchecked=true|No|1,024 -> 1,024|
|UCS L10, one mixed file, unchecked=true|No|1,024 -> 1,024|
|LCS, one mixed file, unchecked=false|Yes, tombstone compaction|1,024 -> 0|
|LCS, one mixed file, unchecked=true|Yes, tombstone compaction|1,024 -> 0|
The live rows remain in all cases. There is no older external SSTable in this
basic case, so an external file does not explain why UCS selects no task.
Control tests also show that UCS removes tombstones during normal compaction of
four overlapping files, and drops a fully expired file when it is safe. Setting
UCS to `L10` does not enable the LCS single-SSTable selection path.
> Add optional single-SSTable tombstone compaction to UCS using the existing
> LCS checks and options
> -------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-21842
> URL: https://issues.apache.org/jira/browse/CASSANDRA-21842
> Project: Apache Cassandra
> Issue Type: Improvement
> Reporter: koo
> Priority: Normal
>
> h3. Description
> UCS does not select a single SSTable for tombstone compaction when the file
> contains both live data and removable tombstones, and no normal compaction
> candidate exists.
> LCS handles this case through single-SSTable tombstone compaction. Without
> this path, UCS may keep removable tombstones when no new data arrives.
> h3. Steps to reproduce
> Use a new, empty table for each case. The results below are from a
> controlled local storage-engine test.
>
> 1. Create a table with PRIMARY KEY (shard, task) and a text value column.
> 2. Use UCS with scaling_parameters=T4, gc_grace_seconds=0, and
> tombstone_compaction_interval=0. Disable automatic compaction while preparing
> the data.
> 3. In each of 32 partitions, insert 16 rows at task keys 0, 3, 6, ...,
> using timestamp 100.
> 4. Delete each range from task to task + 1, using timestamp 200.
> 5. Insert one live row per partition at task key 100000, using timestamp
> 300.
> 6. Flush once to create one SSTable containing live rows and range
> tombstones.
> 7. Once the tombstones are old enough to remove, check whether the strategy
> selects a background compaction task. Execute it if selected.
> 8. Repeat with LCS and with both values of unchecked_tombstone_compaction.
>
> These settings are for an isolated test only.
> h3. Actual result
> | Case | Task selected | Range tombstone markers before -> after |
> | --- | --- | --- |
> | UCS T4, one mixed file, unchecked=false | No | 1,024 -> 1,024 |
> | UCS T4, one mixed file, unchecked=true | No | 1,024 -> 1,024 |
> | UCS L10, one mixed file, unchecked=true | No | 1,024 -> 1,024 |
> | LCS, one mixed file, unchecked=false | Yes, tombstone compaction | 1,024 ->
> 0 |
> | LCS, one mixed file, unchecked=true | Yes, tombstone compaction | 1,024 ->
> 0 |
> All 32 live rows remain. The marker count represents the start and end
> boundaries of 512 range tombstones.
>
> There are no older external SSTables in this test. UCS also removes
> tombstones successfully when normal compaction is triggered with four
> overlapping files.
> h3. Proposed change
> Add an optional single-SSTable tombstone compaction path to UCS when no
> normal compaction or whole-file expiration task is selected.
> Reuse the existing LCS checks and settings:
> - tombstone_threshold
> - tombstone_compaction_interval
> - unchecked_tombstone_compaction
> Keep the existing tombstone removal safety checks unchanged.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]