imbajin commented on code in PR #439:
URL: https://github.com/apache/hugegraph-ai/pull/439#discussion_r4654985842
##########
ontogeny/server/ontogeny/action/runtime.py:
##########
@@ -104,6 +105,13 @@ def __init__(
# (PO-000001 twice). The insert guard turns restart-time collisions
# into a 409 instead of duplicate alive rows.
self._id_seq: dict[str, int] = {}
+ # R3: per-key asyncio locks serializing concurrent same-key idempotent
+ # replays on SQLite (which has no advisory lock). Only one caller then
+ # executes the effects and records its revision; the rest replay the
+ # committed revision. The (action, principal, idempotency_key) unique
+ # index stays as the final backstop for writers this lock cannot cover
+ # (multi-process deployments, dialect-specific paths).
+ self._key_locks: dict[tuple[str, str, str], asyncio.Lock] = {}
Review Comment:
**⚠️ Preserve the lock registry across service rebuilds**
`ServiceContext.publish()` and `reload()` rebuild services and construct a
new `ActionRuntime`. If a same-key request is still executing on the old
runtime when that happens, a request on the new runtime acquires a different
lock and can enter the effects concurrently. The unique index can then reject
the retry rather than replay it, even if the lock is extended through commit.
Share the registry across runtime replacements and cover an in-flight action
during reload. This race follows from source inspection; I did not reproduce it
at runtime.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]