Messaging: one global lock order (fixes a deadlock) #95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "messaging-lock-order"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Router.advancelocked the request, then the connector (the command outbox).Inbound.processlocked the connector, then the message, then the request. A status event and the next attempt of the same request on the same remote connector could deadlock; Postgres aborts one side.Fix: one order everywhere, documented in
Karta.Messaging.LocksandKarta.Messaging: connector, command, request, message.advancelocks the request's remote connectors first;Attempts,receipt_check,ProviderEventsandInboundtake request before message.Locks.retryreruns top-level work (Inbound, ProviderEvents, advance, Commands.finished) if Postgres still aborts one.Tests (
lock_order_test.exs, real connections, no retry allowed): the two paths run against each other through thebefore_attempthook; the mutation check (removing the connector pre-lock) gives40P01. Also a forced deadlock that is retried and completes, and a non-deadlock error that is not retried.Bird echo: Bird's documentation says events echo the send's
tagsandmetadata, so matching an early report bydata.metadata.karta_message_idrests on documentation, not on a seen report. It is not a new assumption, but the acceptance run must confirm it (added to the new "Before switching on" checklist indocs/suite/release-1.0/karta-messaging.md).🤖 Generated with Claude Code