sangkyoonnam commented on code in PR #1386:
URL: https://github.com/apache/flink-agents/pull/1386#discussion_r4559993657
##########
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:
A TTL under 1 ms passes this check, but Flink's `StateTtlConfig` requires
`ttl.toMillis() > 0`, so `short-term-memory.state-ttl: 500 us` fails with "TTL
is expected to be positive." at operator startup. I reproduced that with this
PR's `DurationFormat` and flink-core 2.3.0. Failing with the option name seems
clearer than Flink's message:
```suggestion
if (!DurationFormat.isPositive(ttl)) {
return;
}
if (ttl.toMillis() == 0) {
throw new IllegalArgumentException(
AgentExecutionOptions.SHORT_TERM_MEMORY_STATE_TTL.getKey()
+ " must be at least 1 ms, got "
+ DurationFormat.format(ttl));
}
```
Rounding up to 1 ms would also work if you'd rather not fail. Either way,
the "positive duration enables expiration" wording in both docs pages and the
Java and Python option descriptions should mention the 1 ms floor. Which do you
prefer?
--
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]