A race condition in recovery causes unrecoverable gaps in acked offsets and consequently blocks committing
@wbarnha já está trabalhando nisso.
Desde 4/1/2024.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 1.9k
- Forks
- 205
- Merge médio
- 2h 2min
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de faust-streaming/faust
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
faust-streaming/faust#804 ·
-
scripts/install script forces use of ./venv virtualenv, impossible to use with virtualenvwrapperAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 62/100
faust-streaming/faust#28 · 1 comentário ·
-
[BUG] SASL PLAINTEXT producer initialization fails : missing sasl_plain_username/passwordTalvez já em andamento @wbarnha assumiu há 56 dias. Aberta
faust-streaming/faust#794 · 2 comentários · 1 reação · 2 responsáveis ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 18/100
faust-streaming/faust#670 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 18/100
faust-streaming/faust#666 ·
Todas as issues de faust-streaming/faust
Issues semelhantes
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shardsAbertastatus/accepted type/bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
microsoft/apm#5309 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug vector-store
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
EverMind-AI/Raven#1413 ·
Mantenedores costumam responder em até 1 dia
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
Mantenedores costumam responder em até 2 dias