You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "wellkilo (via GitHub)" <gi...@apache.org> on 2026/09/28 13:57:16 UTC
[I] [Bug][runtime] Kafka action-state writes ignore asynchronous producer failures [flink-agents]
wellkilo opened a new issue, #1173:
URL: https://github.com/apache/flink-agents/issues/1173
### Search before asking
- [x] I searched the open issues and pull requests and found nothing similar.
### Description
`KafkaActionStateStore.put()` currently ignores the `Future<RecordMetadata>` returned by `Producer.send()`:
```java
producer.send(kafkaRecord);
actionStates.put(stateKey, state);
producer.flush();
```
This catches synchronous `send()` or `flush()` failures, but not a record-level failure reported asynchronously by Kafka after `send()` returns. `flush()` waits for outstanding sends to finish; it does not surface the exception stored in each send future.
As a result, a broker acknowledgement failure can be treated as a successful durable-state write. The state is placed in the attempt-local cache and action execution continues. A later checkpoint can capture Kafka end offsets that do not include the failed record. After failover, recovery cannot find the completed action state and may execute the action and its external side effects again.
This affects both initial action-state writes and completed-action writes because they share `KafkaActionStateStore.put()`. Java and Python agent paths both use the same Java runtime store.
### How to reproduce
Kafka's `MockProducer` demonstrates the relevant API behavior deterministically:
```java
MockProducer<String, String> producer =
new MockProducer<>(false, null, new StringSerializer(), new StringSerializer());
Future<RecordMetadata> future =
producer.send(new ProducerRecord<>("topic", "key", "value"));
assertTrue(producer.errorNext(new RuntimeException("broker ack failed")));
assertDoesNotThrow(producer::flush);
assertThrows(ExecutionException.class, future::get);
```
A regression test against `KafkaActionStateStore.put()` can inject the same failed future and assert that the method propagates the failure instead of returning normally.
### Proposed fix
Wait for the future returned by the specific `send()` before updating the in-memory cache. This keeps the existing synchronous persistence contract while making record-level Kafka errors observable to `DurableExecutionManager`, which already propagates persistence failures to fail the task.
The change does not require a public API, event schema, checkpoint format, or configuration change.
### Version and environment
Current `main` (`2e97add7`, `0.4-SNAPSHOT`), Kafka client 4.0.0. The behavior is not broker- or platform-specific.
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
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: issues-unsubscribe@flink.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][runtime] Kafka action-state writes ignore asynchronous producer failures [flink-agents]
Posted by "wellkilo (via GitHub)" <gi...@apache.org>.
wellkilo commented on issue #1173:
URL: https://github.com/apache/flink-agents/issues/1173#issuecomment-5871774759
I have prepared a focused patch on my fork: https://github.com/wellkilo/flink-agents/commit/c73dd081c0bdccfaf71c058868306dfa11535706. It waits for the Kafka send acknowledgement before flushing and updating the attempt-local cache, propagates asynchronous broker failures, and preserves the interrupt flag when the wait is interrupted. Verification completed: KafkaActionStateStoreTest (51/51), repository lint/Spotless, and Apache RAT all pass. If a committer supports this approach, I will open the PR in accordance with the contribution policy.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][runtime] Kafka action-state writes ignore asynchronous producer failures [flink-agents]
Posted by "wellkilo (via GitHub)" <gi...@apache.org>.
wellkilo commented on issue #1173:
URL: https://github.com/apache/flink-agents/issues/1173#issuecomment-5885740061
Thanks @wenjin272 for confirming the approach. I opened #1177 for review: https://github.com/apache/flink-agents/pull/1177. The PR links this issue and contains the tested patch plus regression coverage for the asynchronous acknowledgement failure and interruption behavior.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][runtime] Kafka action-state writes ignore asynchronous producer failures [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on issue #1173:
URL: https://github.com/apache/flink-agents/issues/1173#issuecomment-5885663762
Thanks for preparing the patch @wellkilo. The proposed approach looks reasonable: wait for the send acknowledgement before updating the cache, propagate asynchronous failures, and preserve the interrupt flag. Please go ahead and open the PR for review.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org