Skip to content

Multiple wait events fix and machineId supported#46

Merged
marcopiraccini merged 2 commits into
mainfrom
duplicate-wait-fix
May 13, 2026
Merged

Multiple wait events fix and machineId supported#46
marcopiraccini merged 2 commits into
mainfrom
duplicate-wait-fix

Conversation

@marcopiraccini
Copy link
Copy Markdown
Contributor

@marcopiraccini marcopiraccini commented May 13, 2026

Summary

Fixes two issues surfaced while running the birthday-card-generator example against the local Platformatic cluster:

  1. Duplicate wait_* events crash workflow replay. The SELECT-then-INSERT in plugins/events.ts races under concurrent dispatch retries, producing two wait_created / wait_completed rows for the same correlation_id. The SDK then fails replay with Unconsumed event in event log and the run dead-letters.

  2. ICC handler registration rejected. ICC PR icc3#788 renamed podIdmachineId in the body it POSTs to /api/v1/apps/:appId/handlers. The workflow service still required podId and 400'd every registration, so workflow_queue_handlers stayed empty and queue messages had nowhere to dispatch.

Changes

  • migrations/003.do.sql — partial unique index (run_id, event_type, correlation_id) for wait_created and wait_completed. Intentionally does not cover hook_*: createHook async iterators legitimately produce multiple hook_received events on the same correlation id.
  • plugins/events.tsinsertEvent uses INSERT … ON CONFLICT DO NOTHING for the deduped types and falls back to a SELECT when the conflict fires, so callers still receive a row.
  • plugins/handlers.ts/handlers accepts either podId (legacy) or machineId (post-#788), keeping the existing contract working while letting current ICC clients register.

Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
@marcopiraccini marcopiraccini marked this pull request as ready for review May 13, 2026 11:28
@marcopiraccini marcopiraccini changed the title multiple wait events fix and machineId supported Multiple wait events fix and machineId supported May 13, 2026
Copy link
Copy Markdown
Member

@ivan-tymoshenko ivan-tymoshenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@marcopiraccini marcopiraccini merged commit 494e46d into main May 13, 2026
3 checks passed
@mcollina mcollina deleted the duplicate-wait-fix branch May 14, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants