AlarmAckWriter: stale late write completion can be credited to the next ack if MXAccess reuses an item handle number #166
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
AlarmAckWriterwaits forOnWriteCompletethroughMxAccessWriteCompletionCache.TryWaitForCompletion(src/ZB.MOM.WW.MxGateway.Worker/MxAccess/AlarmAckWriter.cs:207). The cache matches completions only on(serverHandle, itemHandle)plus a version baseline; there is no per-write id.Current mitigation (PR #162): after an
Unconfirmedack the item is markedDirty. The next ack removes it and re-adds it, so a late completion for the old handle should not match the new write.Remaining risk: the mitigation assumes MXAccess hands out a new handle number on re-add. If MXAccess reuses the number, or delivers a completion for a removed handle that is later reused, the stale completion can still be credited to the next ack. The next ack would then report a false
Appliedor a falseWriteRejected.To do:
RemoveItem+AddItemof the same<tag>.AckMsgreuses the handle number. A small probe that adds, removes and re-adds, logging the handles, is enough.Write, or keep a per-handle generation counter in the cache that is bumped on re-add.Found in the final review of PR #162 (feat/ackmsg-as-operator); left unfixed by decision as Minor.
https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT
Probe run on windev 2026-10-20 (Probes/ItemHandleReuseProbeTests.cs, bd82036/463748e): MXAccess does NOT reuse item handle numbers within a registration (remove/re-add of the same AckMsg item gave 1..15 strictly increasing). Numbering restarts on a new registration, which is safe because teardown unhooks OnWriteComplete and clears that server's cache entries. No generation counter needed; the evidence is in docs/AlarmProbeFindings.md and the probe now asserts strictly increasing handles so a re-run is a regression check. Closes when PR #162 merges.
https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT