A race condition in recovery causes unrecoverable gaps in acked offsets and consequently blocks committing

Offen
#596 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@wbarnha arbeitet bereits daran.

Seit 04.1.2024.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

bug

Checklist

  • I have included information about relevant versions
  • I have verified that the issue persists when using the master branch 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 stream to 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.

Messages never being acked cause the committing task to hang because there is no contiguous sequence of offsets.

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

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus faust-streaming/faust

Alle Issues in faust-streaming/faust

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.