test(script-worker): #1100 size the remaining tight liveness bounds for ~1 s whole-process stalls, each still failing on its defect
Audit of the heartbeat / silence / liveness-kill bounds in ScriptWorker.Tests after cb5250fac (#1092):
- PipeFaultTests (reader stalls, heartbeats continue): silence 5 x 200 ms = 1 s -> 2 s, write-stall 2 s -> 5 s.
The silence limit must stay below the write-stall limit or "killed unresponsive, not for silence" proves
nothing. Mutation (worker stops heartbeating when its reader stalls): KilledHeartbeat at ~2 s, test fails.
- WorkerSoftClockTests.The_progress_ceiling_leaves_a_worker_that_keeps_answering_alone: ceiling 1 s over
20 x 150 ms -> 2.5 s over 40 x 150 ms. Mutation (no progress stamp on a Results frame): killed
KilledUnresponsive, queued runs complete null, test fails.
- SupervisionTests burst test: kept at 3 s (production's limit; frames every 50 ms, so only a ~2.95 s stall
trips it; raising it would stop it catching the 3 s windev defect). Comment records the decision.
- The two #1092 tests (1.5 s) and the never-reports-progress test (lower bound only) are already stall-safe.
Stall check, temporary instrumentation (libc kill SIGSTOP/SIGCONT of the worker pid, not committed): a 1.2 s
stall failed the old PipeFault bounds 3/3 and a 1 s stall failed the old ceiling bounds; the new bounds passed
1.2 s stalls 3/3 each. (A first attempt that spawned /bin/kill measured a 2.5 s stall, not 1 s — process
spawn on the loaded box — and was discarded.)
This commit is contained in:
@@ -65,6 +65,18 @@ public sealed class PipeFaultTests
|
||||
/// starts only when the worker starts it) blocks in the write. The write-stall check must kill the worker within
|
||||
/// its bound — as unresponsive, not for silence, which proves it kept heartbeating — and that releases the producer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The two bounds are relative: the silence limit must stay well below the write-stall limit, or a worker (or a
|
||||
/// host reader) that stopped heartbeating along with the reader would also be killed "unresponsive" and the
|
||||
/// assertion would prove nothing. lmxopcua#1100 sizes them for whole-process stalls of a swapping dev box (see
|
||||
/// SupervisionTests' #1092 remarks: 290–380 ms late beats measured at the worker, ~1 s observed): the silence
|
||||
/// limit was 5 × 200 ms = 1 s, which a 1 s stall reaches; it is now 2 s (10 intervals — a stall must exceed ~1.8 s),
|
||||
/// and the write-stall limit 5 s (was 2 s) so a silent worker is still killed for silence 3 s before the write-stall
|
||||
/// check could fire. Mutation check: a worker that stops its heartbeat when its reader stalls exits
|
||||
/// KilledHeartbeat at ~2 s, which releases the producer before the stallLimit / 2 positive control, and the test fails.
|
||||
/// Stall check (temporary, not committed): the worker SIGSTOPped for 1.2 s right after its reader stopped failed the
|
||||
/// old bounds 3 of 3 runs (killed for silence) and passed the new ones 3 of 3.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task A_worker_that_stops_reading_but_keeps_heartbeating_is_killed_and_the_blocked_producer_returns()
|
||||
{
|
||||
@@ -77,8 +89,8 @@ public sealed class PipeFaultTests
|
||||
var warm = await connection.EnsureLoadedAsync("k", ContextKind.VirtualTag, Healthy,
|
||||
SHA256.HashData(Encoding.UTF8.GetBytes(Healthy)), []).WaitAsync(TimeSpan.FromSeconds(60), Ct);
|
||||
warm.Outcome.ShouldNotBeNull().Ok.ShouldBeTrue();
|
||||
connection.SilenceLimit = heartbeat * 5; // armed once the cold start is over (see SupervisionTests)
|
||||
var stallLimit = TimeSpan.FromSeconds(2);
|
||||
connection.SilenceLimit = heartbeat * 10; // armed once the cold start is over (see SupervisionTests); see remarks (#1100)
|
||||
var stallLimit = TimeSpan.FromSeconds(5);
|
||||
connection.WriteStallLimitOverride = stallLimit;
|
||||
|
||||
_ = connection.DiagnosticsAsync(TimeSpan.FromSeconds(60)); // the worker's reader stops here for good
|
||||
|
||||
@@ -146,7 +146,9 @@ public sealed class SupervisionTests
|
||||
// under 28 CPU burners, every compile on its dedicated thread), and at ~300 even a 1 s limit was hit once in 10
|
||||
// (1,012 ms). The limit is now PRODUCTION's (3 × the default 1 s heartbeat): the test kills only where a real node
|
||||
// would, and the windev defect (no frame for 3 s, the whole burst) is still the size it catches. The 50 ms
|
||||
// heartbeat keeps frames flowing for the silence clock.
|
||||
// heartbeat keeps frames flowing for the silence clock. lmxopcua#1100 audit: kept as is — with a frame every 50 ms
|
||||
// (plus every LoadResult) only a stall of ~2.95 s trips it, three times the ~1 s whole-process stalls measured for
|
||||
// #1092, and raising it past production's limit would stop the test catching the 3 s windev defect.
|
||||
worker.SilenceLimit = TimeSpan.FromSeconds(3);
|
||||
|
||||
const int count = 1500;
|
||||
|
||||
@@ -395,6 +395,17 @@ public sealed class WorkerSoftClockTests
|
||||
}
|
||||
|
||||
/// <summary>Positive control for the ceiling: the default rule leaves a busy, answering worker alone.</summary>
|
||||
/// <remarks>
|
||||
/// lmxopcua#1100: the ceiling was 1 s over 20 × 150 ms runs (~3 s). A whole-process stall of about 1 s on a swapping
|
||||
/// dev box (see SupervisionTests' #1092 remarks) is a 1.15 s gap between two answers, past that ceiling, so a
|
||||
/// healthy worker could be killed. Now the ceiling is 2.5 s over 40 runs (~6 s): a gap must exceed ~2.3 s of stall
|
||||
/// to trip it, while the defect the test guards — progress not advanced by each answer, so the ceiling runs from
|
||||
/// the batch's submit — still kills the worker 3.5 s before the batch could finish. Mutation check: drop the
|
||||
/// progress stamp on a Results frame (<c>WorkerConnection.HandleFrame</c>) and the worker is killed
|
||||
/// (KilledUnresponsive), so the remaining runs complete null and the test fails. Stall check (temporary, not
|
||||
/// committed): the worker SIGSTOPped for 1 s mid-batch was killed under the old bounds (KilledUnresponsive at the
|
||||
/// resume, every queued run completed null); under the new ones it survived 1.2 s stalls 3 of 3 runs.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task The_progress_ceiling_leaves_a_worker_that_keeps_answering_alone()
|
||||
{
|
||||
@@ -407,10 +418,10 @@ public sealed class WorkerSoftClockTests
|
||||
var entry = await connection.EnsureLoadedAsync("k", ContextKind.VirtualTag, spin,
|
||||
SHA256.HashData(Encoding.UTF8.GetBytes(spin)), []).WaitAsync(TimeSpan.FromSeconds(60), Ct);
|
||||
entry.Outcome.ShouldNotBeNull().Ok.ShouldBeTrue();
|
||||
// Ceiling 1 s; 20 runs of 150 ms queued behind one evaluation thread take ~3 s, but each answers.
|
||||
connection.ProgressCeilingOverride = TimeSpan.FromSeconds(1);
|
||||
// Ceiling 2.5 s; 40 runs of 150 ms queued behind one evaluation thread take ~6 s, but each answers (see remarks).
|
||||
connection.ProgressCeilingOverride = TimeSpan.FromSeconds(2.5);
|
||||
var soft = TimeSpan.FromSeconds(30);
|
||||
var pendings = connection.SubmitBatch(Enumerable.Range(0, 20).Select(_ => new BatchSubmission("k",
|
||||
var pendings = connection.SubmitBatch(Enumerable.Range(0, 40).Select(_ => new BatchSubmission("k",
|
||||
new EvalRequest { Key = "k", SoftTimeoutMs = 30_000, HardGraceMs = 60_000, NowUtcTicks = DateTime.UtcNow.Ticks },
|
||||
soft, TimeSpan.FromSeconds(60), null)).ToArray());
|
||||
foreach (var p in pendings) (await p.Completion.WaitAsync(TimeSpan.FromSeconds(30), Ct)).ShouldNotBeNull();
|
||||
|
||||
Reference in New Issue
Block a user