AlarmAckWriter: write-completion cache keeps entries for dropped item handles #165

Open
opened 2026-10-20 07:04:21 -04:00 by dohertj2 · 1 comment
Owner

After an ack ends Unconfirmed, AlarmAckWriter marks the item Dirty (src/ZB.MOM.WW.MxGateway.Worker/MxAccess/AlarmAckWriter.cs:215). The next ack then drops and re-adds the item to get a fresh handle (:151). LRU eviction and TearDownServer drop handles too.

Problem: MxAccessWriteCompletionCache (src/ZB.MOM.WW.MxGateway.Worker/MxAccess/MxAccessWriteCompletionCache.cs) keeps its (serverHandle, itemHandle) entry for every dropped handle; nothing removes it. The cache grows slowly for the life of the worker, by one entry per unconfirmed ack and per evicted item.

Suggested fix: add a Remove(serverHandle, itemHandle) (and a clear-by-server for teardown) to MxAccessWriteCompletionCache. Call it from AlarmAckWriter's drop, evict and teardown paths. Add a unit test that the entry count returns to baseline after a dirty re-add and after an eviction.

Found in the final review of PR #162 (feat/ackmsg-as-operator); left unfixed by decision as Minor.

https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT

After an ack ends `Unconfirmed`, `AlarmAckWriter` marks the item `Dirty` (`src/ZB.MOM.WW.MxGateway.Worker/MxAccess/AlarmAckWriter.cs:215`). The next ack then drops and re-adds the item to get a fresh handle (`:151`). LRU eviction and `TearDownServer` drop handles too. **Problem:** `MxAccessWriteCompletionCache` (`src/ZB.MOM.WW.MxGateway.Worker/MxAccess/MxAccessWriteCompletionCache.cs`) keeps its `(serverHandle, itemHandle)` entry for every dropped handle; nothing removes it. The cache grows slowly for the life of the worker, by one entry per unconfirmed ack and per evicted item. **Suggested fix:** add a `Remove(serverHandle, itemHandle)` (and a clear-by-server for teardown) to `MxAccessWriteCompletionCache`. Call it from `AlarmAckWriter`'s drop, evict and teardown paths. Add a unit test that the entry count returns to baseline after a dirty re-add and after an eviction. Found in the final review of PR #162 (feat/ackmsg-as-operator); left unfixed by decision as Minor. https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT
Author
Owner

Fixed on feat/ackmsg-as-operator (PR #162) in f13950e + 463748e. MxAccessWriteCompletionCache gained Remove/RemoveServer/Count; the writer removes entries on dirty re-add, eviction, failed add/advise/write and teardown, and ignores late OnWriteComplete events for handles it no longer holds (so they can't recreate an entry). Tests cover each path. windev Worker.Tests 585/0. Closes when PR #162 merges.

https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT

Fixed on feat/ackmsg-as-operator (PR #162) in f13950e + 463748e. MxAccessWriteCompletionCache gained Remove/RemoveServer/Count; the writer removes entries on dirty re-add, eviction, failed add/advise/write and teardown, and ignores late OnWriteComplete events for handles it no longer holds (so they can't recreate an entry). Tests cover each path. windev Worker.Tests 585/0. Closes when PR #162 merges. https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/mxaccessgw#165