HsbcJone commented on code in PR #1386:
URL: https://github.com/apache/flink-agents/pull/1386#discussion_r4560164260
##########
runtime/src/main/java/org/apache/flink/agents/runtime/operator/OperatorStateManager.java:
##########
@@ -141,15 +142,15 @@ void initializeKeyedStates(
}
/**
- * When {@link AgentExecutionOptions#SHORT_TERM_MEMORY_STATE_TTL_MS} is
positive, attaches Flink
+ * When {@link AgentExecutionOptions#SHORT_TERM_MEMORY_STATE_TTL} is
positive, attaches Flink
* {@link StateTtlConfig} to the short-term memory {@link
MapStateDescriptor}. Unset, null, or
* non-positive values disable TTL (Flink does not allow zero/negative
TTL).
*/
private void maybeEnableShortTermMemoryTTL(
MapStateDescriptor<String, MemoryObjectImpl.MemoryItem> descriptor,
AgentConfiguration agentConfiguration) {
- Long ttlMs =
agentConfiguration.get(AgentExecutionOptions.SHORT_TERM_MEMORY_STATE_TTL_MS);
- if (ttlMs == null || ttlMs <= 0) {
+ Duration ttl =
agentConfiguration.get(AgentExecutionOptions.SHORT_TERM_MEMORY_STATE_TTL);
+ if (!DurationFormat.isPositive(ttl)) {
return;
}
Review Comment:
Thanks for catching this and reproducing it against flink-core 2.3.0. I went
with rejecting the value rather than rounding it up, so something like `500 us`
fails when the operator registers keyed state:
`short-term-memory.state-ttl must be at least 1 ms, got 500 us`
Zero or negative durations still disable TTL. A duration of at least 1 ms,
including `1500 us`, is kept as-is. The option descriptions and both docs pages
now mention the 1 ms floor.
Python only stores this option, so the Java operator remains the single
check for both languages. I did not add a second Python-side check, which would
reject the value at configuration time on Python while Java still accepted it
until operator startup.
Pushed in a67f9d8, with `OperatorStateManagerShortTermMemoryTtlTest`
covering the reject, disable, and enable cases.
--
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]