# Unexpected Behavior with TimeWindowCompactionStrategy in ScyllaDB 6.2 Open Source

**URL:** <https://forum.scylladb.com/t/unexpected-behavior-with-timewindowcompactionstrategy-in-scylladb-6-2-open-source/4345>\
**Category:** ScyllaDB\
**Tags:** ttl, compaction, twcs\
**Created:** [January 8, 2025, 4:39am UTC](https://forum.scylladb.com/t/unexpected-behavior-with-timewindowcompactionstrategy-in-scylladb-6-2-open-source/4345 "2025-01-08T04:39:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naman\_kaushik1](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/naman_kaushik1/32/1490_2.png) [@Naman\_kaushik1](https://forum.scylladb.com/u/Naman_kaushik1)\
**Post date:** [January 8, 2025, 4:39am UTC](https://forum.scylladb.com/t/unexpected-behavior-with-timewindowcompactionstrategy-in-scylladb-6-2-open-source/4345/1 "2025-01-08T04:39:02Z")

</div>

Hi Community,

I’m using ScyllaDB 6.1 Open Source and have a table configured to store 30 days of data with the following compaction strategy:

**compaction = {**  
\*\* ‘class’: ‘TimeWindowCompactionStrategy’,\*\*  
\*\* ‘compaction\_window\_size’: ‘3’,\*\*  
\*\* ‘compaction\_window\_unit’: ‘DAYS’\*\*  
**}**

Currently, no reads are performed on this table—only data inserts.

Here’s what I observed:

- Before today (January 7), the table had SSTables grouped in 3-day windows, such as (Dec 23, Dec 25, Dec 28, Dec 31, Jan 3).
- Today (Jan 7), after triggering an autocompaction, I noticed that the compaction created a new table containing only data for Jan 7. The previous 3-day window grouping behavior seems to have changed unexpectedly.

I haven’t manually triggered any compaction apart from observing this autocompaction behavior.

Does anyone have insights into why this might have happened? Could it be related to some internal behavior or a specific setting I might have missed?

Any help or suggestions would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![Naman\_kaushik1](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/naman_kaushik1/32/1490_2.png) [@Naman\_kaushik1](https://forum.scylladb.com/u/Naman_kaushik1)\
**Post date:** [January 13, 2025, 5:55am UTC](https://forum.scylladb.com/t/unexpected-behavior-with-timewindowcompactionstrategy-in-scylladb-6-2-open-source/4345/2 "2025-01-13T05:55:23Z")

</div>

I posted this question a few days ago, but I haven’t received a response yet. I wanted to provide some additional details about the issue I’m facing.

To recap:

I’m using ScyllaDB 6.1 Open Source and have a table configured to store 30 days of data with the following compaction strategy:

**compaction = {**  
\*\* ‘class’: ‘TimeWindowCompactionStrategy’,\*\*  
\*\* ‘compaction\_window\_size’: ‘3’,\*\*  
\*\* ‘compaction\_window\_unit’: ‘DAYS’,\*\*  
\*\* ‘max\_threshold’: ‘32’,\*\*  
\*\* ‘min\_threshold’: ‘4’\*\*  
**}**

**Observations**

1. Pre-7 Jan Behavior: The table had SSTables grouped in 3-day windows, such as (Dec 23, Dec 25, Dec 28, Dec 31, Jan 3).
2. On 7 Jan: After an autocompaction, a new SSTable was created for Jan 7 only, deviating from the expected 3-day grouping behavior.

Additional Issue

Upon further investigation, I noticed that instead of forming a single large SSTable for each 3-day window, there are multiple small SSTables within each window. These smaller SSTables are not being compacted into a single SSTable as I expected, even though the compaction strategy specifies `min_threshold = 4` and `max_threshold = 32`.

Questions

1. Why are these smaller SSTables within the same 3-day window not being compacted into one large SSTable?
2. Are there specific conditions under which TimeWindowCompactionStrategy avoids compacting SSTables, even when the `min_threshold` and `max_threshold` values should allow it?
3. Could there be an issue with autocompaction triggering or the way TimeWindowCompactionStrategy handles compaction windows for insert-only workloads?

I’d appreciate any insights or suggestions to troubleshoot and resolve this issue.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Gabriel](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/gabriel/32/60_2.png) [@Gabriel](https://forum.scylladb.com/u/Gabriel)\
**Post date:** [April 24, 2025, 8:25am UTC](https://forum.scylladb.com/t/unexpected-behavior-with-timewindowcompactionstrategy-in-scylladb-6-2-open-source/4345/3 "2025-04-24T08:25:28Z")

</div>

TWCS only compacts **expired** windows. The **current/active** 3-day window is not compacted by default, your original post is from Jan 8th and you reference files from Jan 7th, so it seems it’s an expected behaviour .

Furthermore,

- **if you’re seeing multiple SSTables in the current window** , and you’re expecting them to compact: they won’t be compacted _yet_.

- The compaction is **delayed until the window is considered “cold”** (i.e., new writes are no longer hitting it).

- If your write volume is **too low** to generate 4 SSTables per window (or it’s spread across the window unevenly), compaction won’t be triggered.
