[ 
https://issues.apache.org/jira/browse/FLINK-41772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated FLINK-41772:
-----------------------------------
    Labels: pull-request-available  (was: )

> StateTtlConfig cleanupInRocksdbCompactFilter ignores periodicCompactionTime
> ---------------------------------------------------------------------------
>
>                 Key: FLINK-41772
>                 URL: https://issues.apache.org/jira/browse/FLINK-41772
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / State Backends
>    Affects Versions: 2.0.0, 1.19.0, 1.20.0, 2.1.0, 2.2.0, 2.3.0
>            Reporter: seokjin shin
>            Priority: Major
>              Labels: pull-request-available
>
> The {{periodicCompactionTime}} passed to 
> {{StateTtlConfig.Builder#cleanupInRocksdbCompactFilter(long 
> queryTimeAfterNumEntries, Duration periodicCompactionTime)}} (added in 
> 1.19.0, FLINK-30854) has no effect on the RocksDB state backend. The column 
> family of the state keeps the periodic compaction time it was opened with (30 
> days by default). {{Duration.ZERO}} does not turn periodic compaction off 
> either, although the Javadoc and the docs say it does.
> h3. How to reproduce
> {code:java}
> StateTtlConfig.newBuilder(Duration.ofDays(1))
>     .cleanupInRocksdbCompactFilter(1000, Duration.ofDays(3))
>     .build();
> {code}
> Register a ValueState with this config on the RocksDB state backend and read 
> {{periodic_compaction_seconds}} of its column family from the latest OPTIONS 
> file: it is 2592000 (30 days), not 259200 (3 days). The same happens with 
> {{Duration.ZERO}} and after restoring from a checkpoint. Checked on 2.3.0 and 
> master (44e6c7fa6e5).
> h3. Cause
> {{RocksDbTtlCompactFiltersManager#configCompactFilter}} sets the value on the 
> Java {{ColumnFamilyOptions}} object after the column family has been created 
> or opened. RocksDB copies the options at that point, so the change never 
> reaches the column family. The TTL filter itself works because the compaction 
> filter factory is shared by reference.
> h3. Workaround
> Set {{state.backend.rocksdb.compaction.filter.periodic-compaction-time}} 
> (works since 2.1.0, FLINK-37668), or call 
> {{ColumnFamilyOptions#setPeriodicCompactionSeconds}} in a 
> {{RocksDBOptionsFactory}}.
> h3. Proposed fix
> Apply the value to the open column family with {{RocksDB#setOptions}}; 
> {{periodic_compaction_seconds}} can be changed on an open column family. 
> Setting it before the column family is opened does not work on restore, 
> because the column families are opened before the {{StateTtlConfig}} is known.
> Apply only a value passed to the two-argument variant, so jobs that use 
> {{cleanupInRocksdbCompactFilter(long)}} keep their current setting.
> The ForSt sync backend has the same problem; I'd fix it in a follow-up after 
> FLINK-40354.
> I have a patch with tests and would like to work on this.



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

Reply via email to