temporalio / temporalio/samples-java

[Bug] moneybatcher sample race condition?

Offen
#749 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
Java
Sterne
258
Forks
189
Ø Merge
6 T. 4 Std.
Gemergte PRs (30 T.)
4

Beschreibung

What are you really trying to do?

I am trying to learn how to do batching using temporal. I found the moneybatch sample and I wanted to make sure that it can handle requests in parallel.

To simulate the behavior, I changed the workflow to withdraw more times than a single batch size as well as added a delay during the deposit call.
What this lead to is that the workflow would continue to run and not complete, it won't even process a single batch.

Describe the bug

This is related to the condition in the workflow:
Workflow.await(() -> count == batchSize);

If count suddenly goes from 0 to a value greater than batchSize, the workflow will continue to run and not complete.

I am new to temporal, so I am not quite sure how to fix this. Is this a bug in the sample or am I doing something wrong?

Image Image
Minimal Reproduction

Download this branch:
https://github.com/derwasp/samples-java/tree/derwasp/moneybatcher

Either run ./run-moneybatch-demo.sh and observe the logs.
Or run the test TransferWorkflowTest and see the failure.

Environment/Versions
  • OS and processor: M4 Mac
  • Temporal Version: (CLI version 1.4.1)
  • Are you using Docker or Kubernetes or building Temporal from source? Docker
Additional context

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem moneybatch sample unter core/src/main/java/io/temporal/samples/moneybatch und führe TransferWorkflowTest aus dem verknüpften Reproduktions-Branch aus. Untersuche die Workflow.await-Bedingung und das Test-Setup für Anfragen, die die Größe eines Batches überschreiten. Als erledigt gilt die Aufgabe, wenn der reproduzierte Workflow abgeschlossen wird und die erwarteten Batches verarbeitet, anstatt blockiert zu bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
distributed-systems
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

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