minxhe opened a new pull request, #29573:
URL: https://github.com/apache/flink/pull/29573

   ## What is the purpose of the change
   
   When an operator uses the State V2 API on a State V1 backend 
(`HashMapStateBackend` or `EmbeddedRocksDBStateBackend`), 
`AsyncKeyedStateBackendAdaptor` ignores any `StateTtlConfig` configured on the 
State V2 descriptor:
   
   - `AsyncKeyedStateBackendAdaptor#createStateInternal` converts the V2 
`StateDescriptor` to a V1 `StateDescriptor` via 
`StateDescriptorUtils.transformFromV2ToV1(...)`.
   - `StateDescriptorUtils` copies only the state name and the serializer or 
`TypeInformation`, dropping `getTtlConfig()`.
   - Because the converted V1 descriptor has no TTL config, `TtlStateFactory` 
never wraps the underlying state, and expired entries are never cleaned up or 
filtered on read.
   
   This PR copies the TTL config onto the converted V1 descriptor in 
`AsyncKeyedStateBackendAdaptor#createStateInternal` when 
`stateDesc.getTtlConfig().isEnabled()` is true.
   
   Jira: https://issues.apache.org/jira/browse/FLINK-41093
   
   ## Brief change log
   
     - Enable TTL on the converted V1 `StateDescriptor` in 
`AsyncKeyedStateBackendAdaptor#createStateInternal` when the V2 descriptor has 
TTL enabled.
     - Add `AsyncKeyedStateBackendAdaptorTest#testStateTtl` covering V2 
`ValueState`, `ListState`, `MapState`, `ReducingState`, and `AggregatingState` 
expiry.
     - Update `RowTimeDeduplicateFunctionTest` and 
`GroupAggregateHarnessTest#testAggregateWithRetraction` so async-state TTL 
expectations match the synchronous path.
     - Un-skip the 4 state-retention tests in `StreamingJoinOperatorTest` for 
async state.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `AsyncKeyedStateBackendAdaptorTest#testStateTtl` and the 4 un-skipped 
`StreamingJoinOperatorTest` cases fail on unmodified `master` because V2 TTL is 
ignored on the adaptor path, and pass with the fix.
   
   ```sh
   ./mvnw -B -ntp -pl flink-runtime -Dflink.forkCountUnitTest=1 \
     -Dtest=AsyncKeyedStateBackendAdaptorTest test
   # 6 run, 0 failures
   
   ./mvnw -B -ntp -pl flink-table/flink-table-runtime 
-Dflink.forkCountUnitTest=1 \
     -Dtest=StreamingJoinOperatorTest,RowTimeDeduplicateFunctionTest test
   # 28 run, 4 skipped, 0 failures
   
   ./mvnw -B -ntp -pl flink-table/flink-table-planner 
-Dflink.forkCountUnitTest=1 \
     -Dtest=GroupAggregateHarnessTest test
   # 30 run, 0 failures
   
   ./mvnw -B -ntp -pl 
flink-runtime,flink-table/flink-table-runtime,flink-table/flink-table-planner \
     spotless:check checkstyle:check
   # 0 violations
   ```
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: yes (V2 states with TTL on V1 backends are now wrapped 
with V1 `TtlSerializer` via `TtlStateFactory`, as intended)
     - The runtime per-record code paths (performance sensitive): yes (only 
when TTL is enabled on V2 state backed by `AsyncKeyedStateBackendAdaptor`)
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: GitHub Copilot CLI 1.0.90-0
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to