Merge #999: shelve expiry emits Unshelved first, script-owned timeouts surface as themselves, pipeline timeout visible to breaker, resilience config fallback, backoff floor, codec exceptions, worker frame cap split
This commit is contained in:
@@ -4665,6 +4665,33 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
StartAcquisitionDemand(ready.DriverInstanceId, desired, ActorRefs.Nobody);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #999 / review K-8: the resilience invoker for a spawn, never throwing. A factory throw (a wrong-shaped
|
||||
/// <c>ResilienceConfig</c> from a restored database, a manual SQL edit or an older build) used to escape
|
||||
/// <see cref="SpawnChild"/> and the handler hosting every driver on the node — and the same artifact was re-applied
|
||||
/// afterwards. Like a driver-factory throw it is a CONFIG error: logged at Error, and the driver runs on its tier
|
||||
/// defaults (no per-instance overrides); only if that throws too does it run with the pass-through invoker.
|
||||
/// </summary>
|
||||
private IDriverCapabilityInvoker CreateInvoker(DriverInstanceSpec spec)
|
||||
{
|
||||
try { return _invokerFactory.Create(spec.DriverInstanceId, spec.DriverType, spec.ResilienceConfig); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex,
|
||||
"DriverHost {Node}: the ResilienceConfig of {Id} ({Type}) could not be applied — the driver runs on its " +
|
||||
"tier-default resilience policy until the config is fixed and redeployed",
|
||||
_localNode, spec.DriverInstanceId, spec.DriverType);
|
||||
}
|
||||
try { return _invokerFactory.Create(spec.DriverInstanceId, spec.DriverType, null); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex,
|
||||
"DriverHost {Node}: no resilience invoker could be built for {Id} ({Type}) — its capability calls run " +
|
||||
"WITHOUT retry/timeout/breaker", _localNode, spec.DriverInstanceId, spec.DriverType);
|
||||
return NullDriverCapabilityInvoker.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnChild(DriverInstanceSpec spec, bool deferSubscriptions = false)
|
||||
{
|
||||
// An instance id removed by an earlier deployment (StopChild ⇒ Evict, which also holds back late
|
||||
@@ -4734,7 +4761,7 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
// route through the retry/breaker/telemetry pipeline. The tier defaults are layered
|
||||
// with the per-instance ResilienceConfig from the artifact; the pass-through factory yields a
|
||||
// no-op invoker on nodes without the real resilience factory bound.
|
||||
var invoker = _invokerFactory.Create(spec.DriverInstanceId, spec.DriverType, spec.ResilienceConfig);
|
||||
var invoker = CreateInvoker(spec);
|
||||
child = Context.ActorOf(
|
||||
_dataWriteRuntime is null ? DriverInstanceActor.Props(
|
||||
driver!,
|
||||
|
||||
@@ -574,7 +574,9 @@ internal sealed class WorkerHost
|
||||
using var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(100));
|
||||
while (await timer.WaitForNextTickAsync())
|
||||
{
|
||||
if (_logSink.Drain() is { } batch) Send(new Envelope { Logs = batch });
|
||||
// #999 / review K-5: cut by BYTES as well as lines — one batch of every buffered line (≤ 1,000 × ~24 KB)
|
||||
// used to exceed the frame cap, fault the writer and exit the worker.
|
||||
foreach (var batch in _logSink.Drain(Math.Max(1, _maxFrameBytes - 1024))) Send(new Envelope { Logs = batch });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,17 +818,39 @@ internal sealed class WorkerHost
|
||||
});
|
||||
}
|
||||
|
||||
public LogBatch? Drain()
|
||||
/// <summary>
|
||||
/// Drains every buffered line into batches of at most <paramref name="maxBatchBytes"/> encoded bytes each
|
||||
/// (#999 / review K-5). A line too large for any batch on its own is counted as dropped.
|
||||
/// </summary>
|
||||
public List<LogBatch> Drain(int maxBatchBytes)
|
||||
{
|
||||
var batches = new List<LogBatch>();
|
||||
var dropped = Interlocked.Exchange(ref _dropped, 0);
|
||||
if (_lines.IsEmpty && dropped == 0) return null;
|
||||
var batch = new LogBatch { Dropped = (uint)dropped };
|
||||
if (_lines.IsEmpty && dropped == 0) return batches;
|
||||
var batch = new LogBatch();
|
||||
var bytes = 0;
|
||||
while (_lines.TryDequeue(out var line))
|
||||
{
|
||||
Interlocked.Decrement(ref _count);
|
||||
var size = line.CalculateSize();
|
||||
var lineBytes = 1 + Google.Protobuf.CodedOutputStream.ComputeLengthSize(size) + size;
|
||||
if (lineBytes > maxBatchBytes - 16)
|
||||
{
|
||||
dropped++;
|
||||
continue;
|
||||
}
|
||||
if (bytes + lineBytes > maxBatchBytes - 16)
|
||||
{
|
||||
batches.Add(batch);
|
||||
batch = new LogBatch();
|
||||
bytes = 0;
|
||||
}
|
||||
batch.Lines.Add(line);
|
||||
bytes += lineBytes;
|
||||
}
|
||||
return batch;
|
||||
batch.Dropped = (uint)dropped;
|
||||
batches.Add(batch);
|
||||
return batches;
|
||||
}
|
||||
|
||||
private static string Truncate(string value, int max) => value.Length <= max ? value : value[..max];
|
||||
|
||||
Reference in New Issue
Block a user