[ 
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 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

A table can become quiet after many deletes. 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.

The local reproduction uses range deletes and keeps live rows in the same file. 
TTL (Time To Live) expiry may lead to a similar mixed-file situation, but a 
separate TTL lifecycle test has not been run for this patch.
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.

  was:
h3. Description
UCS (Unified Compaction Strategy) can keep an SSTable with live data and old 
tombstones when there are no normal compaction candidates.

The live data prevents Cassandra from dropping the whole SSTable. Some 
tombstones may already be safe to remove, but UCS does not select this file for 
a single-SSTable tombstone compaction.

LCS (Leveled Compaction Strategy) 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
A table can become quiet after many deletes. 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.

The local reproduction uses range deletes and keeps live rows in the same file. 
TTL (Time To Live) expiry may lead to a similar mixed-file situation, but a 
separate TTL lifecycle test has not been run for this patch.

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 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
> A table can become quiet after many deletes. 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.
> The local reproduction uses range deletes and keeps live rows in the same 
> file. TTL (Time To Live) expiry may lead to a similar mixed-file situation, 
> but a separate TTL lifecycle test has not been run for this patch.
> 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.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to