A race condition in recovery causes unrecoverable gaps in acked offsets and consequently blocks committing
@wbarnha arbeitet bereits daran.
Seit 04.1.2024.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Checklist
- I have included information about relevant versions
- I have verified that the issue persists when using the
masterbranch of Faust.
Steps to reproduce
Starting from a high-level description of the issue. To illustrate the race condition, we need to look first at some key design aspects:
- Upon restart/rebalance Faust replays messages from the changelog topics (without consuming messages from the input topics)
- Messages are consumed from Kafka asynchronously populating some in-memory queues. Agents will consume from these queues via
async for ... in streamto process the messages. - Once the recovery from changelog topics is completed, Faust listens to the input topics (i.e., non-changelog topics), clearing the contents of all in-memory queues.
- After agents process a message, the message becomes "acked". Faust maintains the offsets of all acked messages and asynchronously commits these acked offsets back to Kafka.
- Faust has a consistency check that requires contiguous acked offsets to commit a new offset. That is, if the committed offset is N, and the acked offsets are N+1, N+2, N+3, Faust can safely commit offset N+3. However, if the committed offset is N, and the acked offsets are N+2, N+3, Faust will wait until N+1 is acked.
With the current setup, some message(s) may never arrive because the queues are cleaned up in flight, thus blocking committing.
- After the recovery is completed, the async flow of messages from non-changelog topics is resumed: https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/tables/recovery.py#L635-L637 The consumption flow is:
- The
Consumerreads messages asynchronously and puts them in theConductorqueue via the callback https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/transport/consumer.py#L1201
- The
- Then we seek the offsets - this is a network call that may take some time, time during which the queues may be populated https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/tables/recovery.py#L640-L642
- Then we signal the resume: https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/tables/recovery.py#L645
- This clears the in-memory queues, if the queues are not empty that means those messages will never get acked: https://github.com/faust-streaming/mode/blob/c0aa58181432402dca30aa5978179383863a185a/mode/utils/queues.py#L78-L89
Messages never being acked cause the committing task to hang because there is no contiguous sequence of offsets.
- https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/transport/consumer.py#L976
- https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/transport/consumer.py#L994
- Computing the new offset to commit fails https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/transport/consumer.py#L1120-L1121
If there are any messages in flight in the queue, they will be cleaned up before being acked.
I think simply moving
https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/tables/recovery.py#L635-L637
after
https://github.com/faust-streaming/faust/blob/6588a9774babd6aee61f2ce69572b167850717b4/faust/tables/recovery.py#L640-L642
will solve the issue.
- Vorherrschende Sprache
- Python
- Sterne
- 1.9k
- Forks
- 205
- Ø Merge
- 2 Std. 2 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus faust-streaming/faust
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 86/100
faust-streaming/faust#804 ·
-
scripts/install script forces use of ./venv virtualenv, impossible to use with virtualenvwrapperOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
faust-streaming/faust#28 · 1 Kommentar ·
-
[BUG] SASL PLAINTEXT producer initialization fails : missing sasl_plain_username/passwordEvtl. vergeben @wbarnha hat das vor 56 Tagen übernommen. Offen
faust-streaming/faust#794 · 2 Kommentare · 1 Reaktion · 2 zugewiesene Personen ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 18/100
faust-streaming/faust#670 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 18/100
faust-streaming/faust#666 ·
Alle Issues in faust-streaming/faust
Ähnliche Issues
-
bug game: 0100FF500E34A000 game: 0400FF500E34A001 mac packing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
jxxghp/MoviePilot#7576 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
jbaruch/software-factory#266 ·
Maintainer antworten meist innerhalb von 1 Tag
-
cron: raise a distinct error when next_fire finds no match in its search bound (from #813 item 5)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag