perf(site-runtime): instance reconcile sweep reads metadata only and fetches config_json just for the instances it repairs (review 2026-10-21 01/SR-P1)
Adds SiteStorageService.GetAllDeployedConfigMetadataAsync. The sweep decides from the projection, then fetches single rows for its starts/restarts off- thread and re-validates them (generation guard, revision match, pipeline/ running guards), releasing the per-revision claim of any repair that does not act. Boot load unchanged.
This commit is contained in:
@@ -194,6 +194,45 @@ public class SiteStorageService
|
||||
IsEnabled: reader.GetInt64(3) != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the deployment-identity metadata of EVERY deployed instance —
|
||||
/// <c>(name, deployment id, revision hash, is_enabled)</c> — without reading the
|
||||
/// <c>config_json</c> column.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Review 2026-10-21 01/SR-P1: the Deployment Manager's instance reconcile sweep runs every
|
||||
/// <c>InstanceSweepIntervalSeconds</c> (default 60 s) and compares only name / enabled /
|
||||
/// revision, but it used to read through <see cref="GetAllDeployedConfigsAsync"/> — on a
|
||||
/// 500-instance site with ~70 KB configs that is ~35 MB of large-object-heap strings per tick
|
||||
/// on a perfectly healthy site, forever. The sweep now reads this projection and fetches the
|
||||
/// full row via <see cref="GetDeployedConfigAsync"/> only for the instances it actually starts
|
||||
/// or restarts. The boot load still uses <see cref="GetAllDeployedConfigsAsync"/> — it runs
|
||||
/// once and needs every blob.
|
||||
/// </remarks>
|
||||
/// <returns>A task that resolves to one metadata row per deployed instance.</returns>
|
||||
public async Task<List<DeployedConfigMetadata>> GetAllDeployedConfigMetadataAsync()
|
||||
{
|
||||
await using var connection = OpenConnection();
|
||||
|
||||
await using var command = connection.CreateCommand();
|
||||
command.CommandText = @"
|
||||
SELECT instance_unique_name, deployment_id, revision_hash, is_enabled
|
||||
FROM deployed_configurations";
|
||||
|
||||
var results = new List<DeployedConfigMetadata>();
|
||||
await using var reader = await command.ExecuteReaderAsync();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
results.Add(new DeployedConfigMetadata(
|
||||
InstanceUniqueName: reader.GetString(0),
|
||||
DeploymentId: reader.GetString(1),
|
||||
RevisionHash: reader.GetString(2),
|
||||
IsEnabled: reader.GetInt64(3) != 0));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores or updates a deployed instance configuration. Uses UPSERT semantics.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user