fix(perf): #996 Wave 4 — blob-free health probes, narrow data-connections load, off-thread coordinator acks + AdminOps audit, events page cap, capped reservations page
C-6: DeploymentQueries projects Deployment without ArtifactBlob (DbHealthProbe, readiness, ClusterOverview, DriverHost boot). C-11/A-5: DraftSnapshotFactory.FromConfigDbForDataConnectionsAsync + one-parse-per-artifact LoadAppliedAsync + capped pickers. H-6: ConfigPublishCoordinator persists acks off the actor thread (AckPersisted); deadline backlog kicked in parallel. H-3: Restart/Reconnect reply = dispatch; ConfigEdit audit written off-mailbox, failure logged not surfaced. U-6: ServerHistorian:MaxEventsPerRead (default 10000) pages HistoryReadEvents; advertised as MaxReturnEventValues. A-8: /reservations active-only by default, projected, capped at 200. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -104,8 +104,9 @@ public sealed class AdminOperationsActor : ReceiveActor
|
||||
Receive<DeployComposed>(HandleDeployComposed);
|
||||
Receive<DeployComposeFailed>(HandleDeployComposeFailed);
|
||||
Receive<TestDriverConnect>(HandleTestDriverConnect);
|
||||
ReceiveAsync<RestartDriver>(HandleRestartDriverAsync);
|
||||
ReceiveAsync<ReconnectDriver>(HandleReconnectDriverAsync);
|
||||
Receive<RestartDriver>(HandleRestartDriver);
|
||||
Receive<ReconnectDriver>(HandleReconnectDriver);
|
||||
Receive<DriverOperationAuditFailed>(HandleDriverOperationAuditFailed);
|
||||
Receive<AcknowledgeAlarmCommand>(HandleAcknowledgeAlarm);
|
||||
Receive<ShelveAlarmCommand>(HandleShelveAlarm);
|
||||
}
|
||||
@@ -773,64 +774,71 @@ public sealed class AdminOperationsActor : ReceiveActor
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleRestartDriverAsync(RestartDriver msg)
|
||||
/// <summary>
|
||||
/// #996 (review H-3): a Restart/Reconnect REPORTS THE DISPATCH, which is what it does. It used to dispatch, then
|
||||
/// write the <c>ConfigEdit</c> audit row inside the same <c>try</c> — so a ConfigDb failure answered "failed" for a
|
||||
/// command that was already on its way to every node (the operator retried ⇒ a second restart, a second data gap),
|
||||
/// and, as a <c>ReceiveAsync</c>, the audit write suspended the whole mailbox (one connect timeout per click
|
||||
/// against an unreachable server; alarm acks and deploys queued behind it). Now both are synchronous receives:
|
||||
/// dispatch, reply, and write the audit row off-thread; an audit failure is logged (with the full record) and
|
||||
/// never changes the operator-visible result.
|
||||
/// </summary>
|
||||
private void HandleRestartDriver(RestartDriver msg) =>
|
||||
DispatchDriverOperation(msg, "restart", msg.DriverInstanceId, msg.ActorByUserName, msg.CorrelationId,
|
||||
new RestartDriverResult(true, null, msg.CorrelationId),
|
||||
_ => new RestartDriverResult(false, ServerFault("RestartDriver", msg.CorrelationId), msg.CorrelationId));
|
||||
|
||||
private void HandleReconnectDriver(ReconnectDriver msg) =>
|
||||
DispatchDriverOperation(msg, "reconnect", msg.DriverInstanceId, msg.ActorByUserName, msg.CorrelationId,
|
||||
new ReconnectDriverResult(true, null, msg.CorrelationId),
|
||||
_ => new ReconnectDriverResult(false, ServerFault("ReconnectDriver", msg.CorrelationId), msg.CorrelationId));
|
||||
|
||||
private void DispatchDriverOperation(
|
||||
object command, string op, string driverInstanceId, string actor, object correlationId,
|
||||
object success, Func<Exception, object> failure)
|
||||
{
|
||||
var replyTo = Sender;
|
||||
try
|
||||
{
|
||||
// Broadcast to every DriverHostActor on every node via the driver-control DPS topic.
|
||||
// Only the host that owns the instance will act; others ignore it (id not found in _children).
|
||||
Dispatch(DriverControlTopic.Name, msg);
|
||||
|
||||
await using var db = await _dbFactory.CreateDbContextAsync();
|
||||
db.ConfigEdits.Add(new ConfigEdit
|
||||
{
|
||||
EntityType = "DriverInstance",
|
||||
EntityId = Guid.TryParse(msg.DriverInstanceId, out var guid) ? guid : Guid.Empty,
|
||||
FieldsJson = $"{{\"op\":\"restart\",\"driverInstanceId\":{System.Text.Json.JsonSerializer.Serialize(msg.DriverInstanceId)}}}",
|
||||
EditedBy = msg.ActorByUserName,
|
||||
SourceNode = Akka.Cluster.Cluster.Get(Context.System).SelfAddress.Host ?? "unknown",
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
_log.Info("AdminOps: RestartDriver dispatched for {DriverInstanceId} by {User}",
|
||||
msg.DriverInstanceId, msg.ActorByUserName);
|
||||
replyTo.Tell(new RestartDriverResult(true, null, msg.CorrelationId));
|
||||
// Broadcast to every DriverHostActor on every node via the driver-control topic. Only the host that owns the
|
||||
// instance acts; others ignore it (id not found in _children).
|
||||
Dispatch(DriverControlTopic.Name, command);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex, "AdminOps: RestartDriver failed for {DriverInstanceId} (correlation {CorrelationId})", msg.DriverInstanceId, msg.CorrelationId);
|
||||
replyTo.Tell(new RestartDriverResult(false, ServerFault("RestartDriver", msg.CorrelationId), msg.CorrelationId));
|
||||
// The ONLY genuine failure: nothing was dispatched.
|
||||
_log.Error(ex, "AdminOps: {Op} dispatch failed for {DriverInstanceId} (correlation {CorrelationId})", op, driverInstanceId, correlationId);
|
||||
replyTo.Tell(failure(ex));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleReconnectDriverAsync(ReconnectDriver msg)
|
||||
{
|
||||
var replyTo = Sender;
|
||||
try
|
||||
_log.Info("AdminOps: {Op} dispatched for {DriverInstanceId} by {User}", op, driverInstanceId, actor);
|
||||
replyTo.Tell(success);
|
||||
|
||||
// Audit off the mailbox. Cluster state is read HERE (actor thread); the DB work is a pool-thread task.
|
||||
var sourceNode = Akka.Cluster.Cluster.Get(Context.System).SelfAddress.Host ?? "unknown";
|
||||
var factory = _dbFactory;
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// Broadcast to every DriverHostActor; only the one owning the instance reacts.
|
||||
Dispatch(DriverControlTopic.Name, msg);
|
||||
|
||||
await using var db = await _dbFactory.CreateDbContextAsync();
|
||||
await using var db = await factory.CreateDbContextAsync().ConfigureAwait(false);
|
||||
db.ConfigEdits.Add(new ConfigEdit
|
||||
{
|
||||
EntityType = "DriverInstance",
|
||||
EntityId = Guid.TryParse(msg.DriverInstanceId, out var guid) ? guid : Guid.Empty,
|
||||
FieldsJson = $"{{\"op\":\"reconnect\",\"driverInstanceId\":{System.Text.Json.JsonSerializer.Serialize(msg.DriverInstanceId)}}}",
|
||||
EditedBy = msg.ActorByUserName,
|
||||
SourceNode = Akka.Cluster.Cluster.Get(Context.System).SelfAddress.Host ?? "unknown",
|
||||
EntityId = Guid.TryParse(driverInstanceId, out var guid) ? guid : Guid.Empty,
|
||||
FieldsJson = $"{{\"op\":\"{op}\",\"driverInstanceId\":{System.Text.Json.JsonSerializer.Serialize(driverInstanceId)}}}",
|
||||
EditedBy = actor,
|
||||
SourceNode = sourceNode,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
_log.Info("AdminOps: ReconnectDriver dispatched for {DriverInstanceId} by {User}",
|
||||
msg.DriverInstanceId, msg.ActorByUserName);
|
||||
replyTo.Tell(new ReconnectDriverResult(true, null, msg.CorrelationId));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex, "AdminOps: ReconnectDriver failed for {DriverInstanceId} (correlation {CorrelationId})", msg.DriverInstanceId, msg.CorrelationId);
|
||||
replyTo.Tell(new ReconnectDriverResult(false, ServerFault("ReconnectDriver", msg.CorrelationId), msg.CorrelationId));
|
||||
}
|
||||
await db.SaveChangesAsync().ConfigureAwait(false);
|
||||
}).PipeTo(Self, failure: ex => new DriverOperationAuditFailed(op, driverInstanceId, actor, correlationId, ex));
|
||||
}
|
||||
|
||||
private void HandleDriverOperationAuditFailed(DriverOperationAuditFailed m) =>
|
||||
_log.Warning(m.Error,
|
||||
"AdminOps: the audit row for {Op} of {DriverInstanceId} by {User} could NOT be written (correlation {CorrelationId}); " +
|
||||
"the command WAS dispatched and the operator was told so",
|
||||
m.Op, m.DriverInstanceId, m.Actor, m.CorrelationId);
|
||||
|
||||
/// <summary>The off-thread ConfigEdit audit write for a dispatched driver operation failed (#996 / H-3).</summary>
|
||||
private sealed record DriverOperationAuditFailed(string Op, string DriverInstanceId, string Actor, object CorrelationId, Exception Error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user