[Feature][runtime] Support durable replay for same-key inputs from multiple upstream instances
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java, kafka
- Ambito
- backend, distributed-systems
Direzione di ricerca
Start with the issue’s referenced OperatorStateManager.initOrIncSequenceNumber and the Kafka/Fluss lookup paths, then read the consistency documentation’s conditions for reusing saved records. Reproduce recovery with two upstream instances sending the same key and reversed interleaving, measuring Action/tool invocations and stateful Memory effects. Done means a designed and tested replay contract covers repeated failures and recovery checkpoints for both Kafka and Fluss, with documentation of prerequisites and fallback behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Search before asking
- I searched the existing issues. #1301 tracks incorrect divergence detection for normal multi-Action execution; #1084 tracks event-occurrence key collisions. Neither restores the original input ordering across upstream channels.
Description
ActionStateStore reuse currently depends on replaying each business key's inputs in the same order. The operator assigns seqNum from a checkpointed per-key counter when it starts a top-level InputEvent; seqNum is not a stable source-record identifier.
When the same business key arrives from multiple upstream parallel instances, keyBy routes those inputs to the same downstream instance but does not establish a replay-stable order across the incoming channels. A failure can therefore assign a different seqNum to the same logical input.
This is a practical limitation for agents consuming merged streams or records distributed across multiple source partitions/upstream instances under the same agent key. Correcting #1301 avoids false invalidation for normal multi-Action execution, but does not eliminate this limitation.
The current consistency documentation already requires stable per-key input order. This issue requests support for the broader topology and a precise user-facing recovery contract, rather than claiming that the existing documentation guarantees it.
Example and impact
Take checkpoint C0 after seqNum=9 for key K. Two upstream instances then emit distinct records for K:
upstream 1: A, C
upstream 2: B, D
original execution:
seq=10: A
seq=11: B
seq=12: C
seq=13: D
completed ActionStates are persisted; failure before the next checkpoint
restore C0, with a different channel interleaving:
seq=10: B
seq=11: A
seq=12: C
seq=13: D
Both deliveries preserve each upstream channel's order, yet the per-key merged sequence differs. The lookup for B at seq=10 cannot find B's completion saved at seq=11. Cache-miss/divergence handling can invalidate the remaining saved suffix, causing completed work to run again.
Even when C returns to its old sequence number, blindly reusing its result is unsafe if its output or Memory updates depended on the earlier processing order. For example, A and B can set the same Memory field to different values, which C then reads.
- Model/tool calls can repeat despite having saved completions.
- If order changes at the first replayed input, reuse for that key's affected replay window can be lost.
- Changes only in the interleaving of different keys do not cause this issue.
- Parallelism or keyBy alone is not sufficient to trigger it: a key with a replay-stable ordered input path can still reuse saved state.
- This is about ActionState reuse and repeated external work; it is not a claim that all Flink checkpointed state or transactional sinks lose their guarantees.
Flink's dataflow documentation explains that redistribution preserves ordering within each sending/receiving subtask pair, not across all senders.
Proposed investigation
Define how agents should recover when same-key inputs originate from multiple channels. Possible directions include durably recording the accepted per-key input order and restoring it, or introducing stable input identity together with the state-dependency semantics required for safe reuse.
A stable input ID alone is insufficient for stateful Actions: recovering a result by ID must not replay Memory changes or outputs computed against a different preceding history. Likewise, disabling divergence protection would mask the mismatch rather than solve it.
A substantial recovery-model change should receive a separate design discussion before implementation.
Acceptance criteria
- Add a controlled recovery test with at least two upstream instances emitting distinct inputs for the same agent key, deliberately reverse their interleaving after failure, and measure actual Action/tool invocations.
- Define and implement a supported replay contract that preserves safe reuse of saved completed work for that topology. If ordering restoration is selected, verify that the accepted history is restored before applying dependent Memory updates.
- Test stateful Actions whose results depend on preceding same-key inputs, not just stateless input-to-output functions.
- Cover repeated failures and checkpoints taken while recovery is progressing; validate both Kafka and Fluss backends.
- Keep different keys isolated and retain the existing ordered-input behavior.
- Document supported topologies, ordering prerequisites, and fallback/re-execution behavior for inputs outside the supported contract. Until broader support exists, explain concretely that keyBy alone does not satisfy the ordering prerequisite.
- Do not weaken the genuine divergence safeguards tracked in #1301.
Version and validation status
Flink Agents 0.4-SNAPSHOT; source analysis used audit baseline 47daff57b5c4189c80dd7037660f2a7832270879, including OperatorStateManager.initOrIncSequenceNumber and the Kafka/Fluss lookup paths.
The sequence-number dependency and invalidation paths were inspected. The separate #1301 prototype exercised controlled changed-input histories through real operator snapshot/restore with mocked broker transport. A live multi-upstream network-shuffle failover reproduction for this issue has not yet been run.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Lingua principale
- Java
- Stelle
- 497
- Fork
- 193
- Merge medio
- 2g 21h
- PR unite (30g)
- 68
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/flink-agents
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/flink-agents#1480 ·
I maintainer di solito rispondono entro 2 giorni
-
[Tech Debt] Python cross-language e2e tests hardcode 0.4-SNAPSHOT tests jar and silently skipAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
apache/flink-agents#1476 ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug][runtime] Trace Log loggers fail on a string trace-log.pretty-print valueForse già presa @Zhuoxi2000 l’ha presa 3 giorni fa. ApertaaffectVersion/0.4.0 bug fixVersion/0.4.1 fixVersion/1.0.0 priority/major
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/flink-agents#1463 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 45/100
apache/flink-agents#1482 ·
I maintainer di solito rispondono entro 2 giorni
-
[java][python][Azure OpenAI] Align token limit handling with max_completion_tokensForse già presa @samarthputhraya l’ha presa oggi. ApertaaffectVersion/0.4.0 bug priority/major
apache/flink-agents#1478 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/flink-agents
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
federicoiosue/Omni-Notes#1044 ·
-
Industrial Center Text TypoApertaBug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Terraform releases proxy leaves a temp folder behind on every cache refreshForse già presa @dhananjay6561 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
terrakube-io/terrakube#4069 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno