fix(worker): ReadBulk never tears down the caller's own item or advice (#238)
ReadBulk served a tag from the cache only when it was advised and cached; every other tag took the AddItem + Advise + wait + UnAdvise + RemoveItem snapshot lifecycle. If AddItem ever returned the caller's existing handle, the teardown would unadvise and remove the caller's subscription. ReadBulk now resolves a tag the session already holds to the session's own item handle in phase 1: - advised but uncached: wait on the caller's subscription for its first OnDataChange (baseline taken in phase 1, before any phase-2 pump can dispatch it); no COM call, no teardown. - added but not advised: advise temporarily, then unadvise only; the item stays registered, and the value the temporary advice cached is dropped so it cannot later be served as was_cached = true. - not held: unchanged snapshot lifecycle. An AddItem that returns a handle the registry already tracks is treated as the caller's (not re-registered, not removed). Duplicate sharing, pump cadence, the shared deadline, timeout reporting and was_cached semantics are unchanged. Live repro on the windev rig (330 advised + 40 added-only tags, immediate 250-tag ReadBulk chunks x4 parallel, 60 s observation): unfixed and fixed workers both keep 290/330 handles delivering. The 40 silent handles are TestHistoryValue, which does not change within the window on either build. The installed MXAccess hands out a distinct handle per AddItem even for an address already added, and UnAdvise/RemoveItem of the second handle leaves the first delivering. So the #238 teardown path does not silence subscriptions on this MXAccess, and this change does not explain the vd03 rate drop. The fix stays as a guard, and it saves an extra item and four COM calls per uncached held tag. Docs: gateway.md, Contracts.md, DesignDecisions.md, MxAccessWorkerInstanceDesign.md and the five client ReadBulk doc comments.
This commit is contained in:
+4
-2
@@ -554,8 +554,10 @@ public final class MxGatewaySession implements AutoCloseable {
|
||||
* <p>MXAccess COM has no synchronous read; the worker returns the cached
|
||||
* {@code OnDataChange} value for any tag that is already advised
|
||||
* ({@code wasCached == true}) without modifying the existing subscription,
|
||||
* and falls back to a full AddItem + Advise + wait + UnAdvise + RemoveItem
|
||||
* snapshot lifecycle otherwise. The supplied {@code timeout} is one shared
|
||||
* Otherwise it waits for the first {@code OnDataChange}: through the
|
||||
* session's own item when the tag is already added (advised temporarily if
|
||||
* needed, never removed), or through a full AddItem + Advise + wait +
|
||||
* UnAdvise + RemoveItem snapshot lifecycle when it is not. The supplied {@code timeout} is one shared
|
||||
* deadline for the whole command, not a per-tag budget: the worker advises
|
||||
* every uncached tag, waits once for all of them, then tears them down.
|
||||
* Pass {@link Duration#ZERO} (or {@code null}) to use the worker default
|
||||
|
||||
Reference in New Issue
Block a user