fix(worker): leave added-only caller items to a snapshot AddItem (#238)
ci / windows-x86 (push) Successful in 2m4s
ci / java (push) Failing after 6m50s
ci / portable (push) Failing after 9m33s

The live run on windev showed MXAccess hands a re-added address a new
handle, so reading a caller's added-but-not-advised item through the
caller's handle (temporary Advise/UnAdvise) touched the caller's item for
no reason. Only an advised-but-uncached caller tag now reuses the caller's
handle (waiting on its existing subscription). Every other tag takes a
snapshot AddItem; if that AddItem returns a handle the registry already
tracks, it is still treated as the caller's item and never removed.

Docs and tests updated to the live observation; the live test now logs
the snapshot handle MXAccess returned for the re-added address.
This commit is contained in:
Joseph Doherty
2026-12-01 19:38:11 -05:00
parent 2e6645ef92
commit cc33b063fa
7 changed files with 154 additions and 107 deletions
+16 -15
View File
@@ -356,18 +356,20 @@ timeout.
`ReadBulk` runs its snapshot lifecycle in phases so the STA is held for at most
one `timeout_ms` per command, not one per tag: (1) every tag is validated and
probed against the registry and the cached-and-advised fast path; (2) every
remaining tag gets an advised handle — a tag the session does not hold gets
the read's own `AddItem`, a tag it holds keeps the caller's item handle, and
the handle is advised only when nothing advises it yet; (3) one wait with a
shared deadline collects the first `OnDataChange` per handle and returns as
soon as all have delivered; (4) teardown, best-effort and ownership-scoped,
unadvises only the advices phase 2 created and removes only the items phase 2
added. The caller's items are therefore never removed and the caller's
subscriptions never unadvised: an advised-but-uncached caller tag is waited on
through the existing subscription with no COM call, and an added-only caller
item is advised for the read and unadvised afterwards, back to its prior
state (#238). A snapshot `AddItem` that returns a handle the registry already
tracks is treated as the caller's item for the same reason. Per-tag
remaining tag gets an advised handle — a tag the caller has advised keeps the
caller's item handle and its existing subscription, any other tag gets the
read's own `AddItem`, and a handle is advised only when nothing advises it
yet; (3) one wait with a shared deadline collects the first `OnDataChange` per
handle and returns as soon as all have delivered; (4) teardown, best-effort
and ownership-scoped, unadvises only the advices phase 2 created and removes
only the items phase 2 added. The caller's items are therefore never removed
and the caller's subscriptions never unadvised (#238). A snapshot `AddItem`
that returns a handle the registry already tracks is the caller's item: it is
advised for the read only if nothing advises it yet, unadvised afterwards,
and never removed. (The windev MXAccess install returns a new handle for a
re-added address, so in practice an added-only caller item is not touched;
the ownership check covers an install or address spelling that resolves to
the caller's handle.) Per-tag
results are unchanged: request order, the blank-address failure, the cached
result, an `AddItem` failure (item handle 0) or `Advise` failure (its own item
handle) failing only that tag, and the `ReadBulk timed out after <n> ms waiting
@@ -750,9 +752,8 @@ registry still tracks belongs to a live item, so its entries are kept.
Successful `UnAdvise` drops the handle pair's `MxAccessValueCache` entry too:
the item stays added, but its value stops updating, so without the eviction a
later re-advise would let `ReadBulk`'s cached path answer with the previous
advice's value (for example the value a `ReadBulk`'s own temporary advice on a
caller's added-only item captured) before the new advice's first
`OnDataChange` lands. Failed advice and cleanup calls
advice's value (including one a `ReadBulk`'s temporary advice on a caller's
handle captured) before the new advice's first `OnDataChange` lands. Failed advice and cleanup calls
leave registry state unchanged so diagnostics continue to reflect the last
successful MXAccess-owned state transition.