fix(dataconn): #1026 name every origin reset cause; stop binding checks invalidating live sources; renew cohort leases in batches
Gate #1026 (2048 projected items, rig seed --scale 2048) still failed after #1115. Three defects, found by first making the origin and the consumer say why: Diagnostics (origin + consumer) - SourceInvalidationReason (bounded enum, classified from the publisher's reason constants): counted per reason (`otopcua.dataconn.source.invalidations{reason}`, `Invalidate.<Reason>` in SourceIngressDiagnostics), recorded on the source and logged at Debug (PartitionedSampleHub.Logger). - An interest lease records why it stopped; the origin Subscribe stream's Reset text names it ("Source invalidated (<reason>).", "Source retired.", "Source interest released.", "Source routing changed.", "Source partition reset.", "Source binding replaced.") instead of always "Source change history expired."; logged at Information (Released at Debug). The texts are for people/counters only: the consumer classifies them into ResetSourceInvalidated / ResetInterestLost (no peer branches on them; the rig probe whitelist is updated). - Consumer: renewal started/succeeded/failed/budget/slot counters, RenewalFail.<point> and AttemptEnd.<reason> (bounded, constant keys). 1. Origin: a binding check invalidated live sources. The driver actor's source-binding retry re-walks every desired reference (offset 0, every <= 30 s once any one failed); for an already-bound reference it took the source's serialization gate, and when the poll thread was publishing that source both sides invalidated it (BindingContention / SerializationContention) and reset every origin stream holding it. Live s1026-c: the only invalidation reasons were those two (5+5 during the open, recurring every ~30 s). EnsureDriverBinding now answers an already-bound, current source without the gate. Live after: 0 BindingContention. 2. Consumer: per-item metadata lease renewal could not keep up. Each projected item renewed its 15 s lease with its own capabilities + GetMetadata pair holding a 256 KiB unary reservation; at the default 1 MiB budget four ran at once and the rest retried on the next 250 ms tick (~16 items/s). Live s1026-d: 155 703 renewals started, 153 019 refused by the unary budget, 2 564 committed; ~1900 of 2048 items stood down BadUserAccessDenied; 0 recovered after the origin restart. RemoteNamespaceResolver.RenewExactBatchAsync renews many items with one capabilities call and one GetMetadata per origin MaxBatchItems (the single-item renewal is now the batch of one: same checks, lease bound and commit); a cohort renews every due item of a tick in batches of 128, and the between-attempt renewal (every item after an origin restart) is batched too. 3. Consumer: two demands of one node in one cohort deadlocked the batch: the second joined (#969) the first's claim, and the batch waited for the joiner before publishing its verdict. The batch now publishes first. Live (OrbStack rig, 160 + 1888 items, 4 Hz churn, SOURCE pair restart): s1026-f run 1 open 10.2 s, recovery 1.5 s, 0 resets of any kind; s1026-h run 2 PASS (open 3.1 s, recovery 3.6 s, 0 resets, no history-expired or source-invalidated log line). Remaining (not fixed here): s1026-h run 1 recovered only 852 of 1888 large-mapping items after the restart: their renewals fail in the catalog cache's predecessor-chain bound (RenewalFail.Cache.PredecessorChain 81 163). Tests: GrpcData1026BindingContentionTests (fails without the fast path), GrpcData1026RenewalBatchWireTests (one tick renews all due items in one metadata call - fails with per-item renewals; two demands of one node - fails without the ordering fix), GrpcData1026ResetReasonTests. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -182,6 +182,18 @@ class ScaleGate:
|
||||
return found
|
||||
time.sleep(3)
|
||||
|
||||
def origin_counters(self):
|
||||
"""#1026 evidence: SOURCE `SourceIngressDiagnostics` (incl. `Invalidate.<Reason>`), non-zero only; process-lifetime."""
|
||||
out = {}
|
||||
for node in ("source-1", "source-2"):
|
||||
try:
|
||||
observed = self.runner.probe(node, "topology", timeout=30)
|
||||
counters = (observed.get("originAccounting") or {}).get("sourceIngressCounters") or {}
|
||||
out[node] = {key: value for key, value in counters.items() if value}
|
||||
except (scenarios.ScenarioError, rig.RigError, OSError) as error:
|
||||
out[node] = {"error": type(error).__name__}
|
||||
return out
|
||||
|
||||
def counters(self, consumers):
|
||||
out = {}
|
||||
mapping = self.scale["mappings"][0]
|
||||
@@ -250,7 +262,10 @@ class ScaleGate:
|
||||
except rig.RigError:
|
||||
hits[node] = None
|
||||
continue
|
||||
hits[node] = [line[-400:] for line in text.splitlines() if "history expired" in line.lower()][:20]
|
||||
hits[node] = [line[-400:] for line in text.splitlines()
|
||||
# #1026: an own-source invalidation used to read "history expired" too. (A released interest
|
||||
# or a partition reset of the origin shutting down is the stream's own teardown, not a loss.)
|
||||
if "history expired" in line.lower() or "stream reset: source invalidated (" in line.lower()][:20]
|
||||
return hits
|
||||
|
||||
def run(self):
|
||||
@@ -295,6 +310,8 @@ class ScaleGate:
|
||||
counters_before = self.counters(consumers)
|
||||
self.evidence["counters_before"] = counters_before
|
||||
self.mark("counters-before", reset_history={n: c.get("ResetHistory") for n, c in counters_before.items()})
|
||||
self.evidence["origin_counters_after_open"] = self.origin_counters()
|
||||
self.mark("origin-counters-after-open", **self.evidence["origin_counters_after_open"])
|
||||
|
||||
stop_churn = threading.Event()
|
||||
churn_steps = []
|
||||
@@ -319,6 +336,9 @@ class ScaleGate:
|
||||
"good_now": sum(1 for item in s.view().values() if cli_gate.is_good_status(item["status"]))}
|
||||
for s in subscribers}
|
||||
self.mark("pre-restart-churn", **self.evidence["pre_restart_churn"])
|
||||
self.evidence["counters_before_restart"] = self.counters(consumers)
|
||||
self.evidence["origin_counters_before_restart"] = self.origin_counters()
|
||||
self.mark("origin-counters-before-restart", **self.evidence["origin_counters_before_restart"])
|
||||
restart_at = time.monotonic()
|
||||
self.mark("origin-restart-begin", nodes=["source-1", "source-2"])
|
||||
runner.rig.compose("restart", "--timeout", "10", "source-1", "source-2", timeout=180)
|
||||
@@ -343,13 +363,22 @@ class ScaleGate:
|
||||
counters_after = self.counters(consumers)
|
||||
self.evidence["counters_after"] = counters_after
|
||||
deltas = {node: {key: counters_after[node].get(key, 0) - counters_before[node].get(key, 0)
|
||||
for key in ("Reset", "ResetHistory", "ResetUnavailable", "ResetSnapshot", "ResetOther", "Attempt", "SnapshotEnd")}
|
||||
for key in ("Reset", "ResetHistory", "ResetUnavailable", "ResetSnapshot", "ResetSourceInvalidated",
|
||||
"ResetInterestLost", "ResetOther", "Attempt", "SnapshotEnd")}
|
||||
for node in consumers}
|
||||
self.evidence["counter_deltas"] = deltas
|
||||
self.mark("counters-after", deltas=deltas)
|
||||
self.evidence["origin_counters_end"] = self.origin_counters()
|
||||
self.mark("origin-counters-end", **self.evidence["origin_counters_end"])
|
||||
self.check(all(delta["ResetHistory"] == 0 for delta in deltas.values()),
|
||||
"no 'Source change history expired.' reset reached either CONSUMER (ResetHistory delta 0)",
|
||||
reset_history={node: delta["ResetHistory"] for node, delta in deltas.items()})
|
||||
# #1026: before the origin named its reset causes, an own-source invalidation and a lost interest also read
|
||||
# "Source change history expired."; they must stay zero too or the renamed text would pass the gate vacuously.
|
||||
self.check(all(delta["ResetSourceInvalidated"] == 0 and delta["ResetInterestLost"] == 0 for delta in deltas.values()),
|
||||
"no origin interest reset of any other cause either (ResetSourceInvalidated / ResetInterestLost delta 0)",
|
||||
source_invalidated={node: delta["ResetSourceInvalidated"] for node, delta in deltas.items()},
|
||||
interest_lost={node: delta["ResetInterestLost"] for node, delta in deltas.items()})
|
||||
self.check(all(counters_after[n].get("ResetHistory", 0) == 0 for n in consumers),
|
||||
"ResetHistory is 0 since CONSUMER process start", totals={n: counters_after[n].get("ResetHistory") for n in consumers})
|
||||
for s in subscribers:
|
||||
|
||||
Reference in New Issue
Block a user