fix(worker): skip cache writes for late callbacks on removed handles (MXA-004, #255)
ci / windows-x86 (push) Failing after 15m0s
ci / java (push) Failing after 15m13s
ci / portable (push) Failing after 15m21s
ci / windows-x86 (push) Failing after 15m0s
ci / java (push) Failing after 15m13s
ci / portable (push) Failing after 15m21s
An OnDataChange/OnWriteComplete already queued on the STA is dispatched after RemoveItem evicted the handle and re-created the cache entry; item handles are never reused within a registration, so it leaked until Unregister. MxAccessSession.Create now binds its handle registry to the production sink, which only caches callbacks for handles the registry still holds. The event is still forwarded. EvictStaleHandleState stays as the backstop for unbound sinks.
This commit is contained in:
@@ -793,13 +793,20 @@ caches the event sink fills: `RemoveItem` drops the handle pair's
|
||||
removes the server's items with it, so the per-item eviction never runs for
|
||||
them). Without this, an `AddItem` → `Write` → `RemoveItem` churn grew the
|
||||
completion cache by one entry per cycle for the life of the worker.
|
||||
`AddItem`, `AddItem2`, and `AddBufferedItem` also drop both cache entries for
|
||||
the handle they receive when the registry does not already track it. An
|
||||
`OnDataChange` or `OnWriteComplete` that was queued when `RemoveItem` or
|
||||
`Unregister` ran is dispatched after the eviction and recreates the entry;
|
||||
when MXAccess later reuses that item id, `ReadBulk`'s cached path would
|
||||
otherwise serve the stale value as `was_cached = true`. A handle the
|
||||
registry still tracks belongs to a live item, so its entries are kept. Failed advice and cleanup calls
|
||||
An `OnDataChange` or `OnWriteComplete` that was queued when `RemoveItem` or
|
||||
`Unregister` ran is dispatched after the eviction. `MxAccessSession.Create`
|
||||
binds the session's handle registry to the production event sink, and the sink
|
||||
writes a cache entry only for an item handle the registry still holds; the
|
||||
event itself is still forwarded to the gateway. Without the check the late
|
||||
callback re-created the entry, and because MXAccess hands out strictly
|
||||
increasing item handles within a registration, nothing evicted it again before
|
||||
`Unregister`: a `ReadBulk` poll loop or subscribe/unsubscribe churn leaked one
|
||||
entry per cycle in the 32-bit worker (MXA-004). As a backstop for a sink that is
|
||||
not bound to a registry, `AddItem`, `AddItem2`, and `AddBufferedItem` also drop
|
||||
both cache entries for the handle they receive when the registry does not
|
||||
already track it, so a reused id never serves a stale value as
|
||||
`was_cached = true`. A handle the registry still tracks belongs to a live item,
|
||||
so its entries are kept. Failed advice and cleanup calls
|
||||
leave registry state unchanged so diagnostics continue to reflect the last
|
||||
successful MXAccess-owned state transition.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user