fix(secrets): jittered exponential backoff in SqlServerSecretsStoreMigrator + 8-way concurrent-migrate live test
Flat 100*attempt backoff let concurrent boots retry in lockstep (Auth's twin loop exhausted retries ~1/60 eight-way boots). Backoff is now exponential with equal jitter, via an injectable Random for deterministic tests. Refs scadaproj#18
This commit is contained in:
+15
-1
@@ -358,6 +358,17 @@ public sealed class SqlServerSecretStoreLiveTests : IAsyncLifetime
|
||||
|
||||
[SkippableFact]
|
||||
public async Task Migrator_converges_when_many_nodes_provision_a_virgin_database_concurrently()
|
||||
=> await ProvisionConcurrentlyAsync(nodes: 4, rounds: 1);
|
||||
|
||||
/// <summary>
|
||||
/// scadaproj#18: the Auth twin of this loop exhausted its retries ~1 in 60 eight-way boots with
|
||||
/// flat back-off; repeated rounds of 8 concurrent migrators against fresh virgin schemas.
|
||||
/// </summary>
|
||||
[SkippableFact]
|
||||
public async Task Migrate_Concurrently_FromEightTasks_AllSucceed()
|
||||
=> await ProvisionConcurrentlyAsync(nodes: 8, rounds: 10);
|
||||
|
||||
private static async Task ProvisionConcurrentlyAsync(int nodes, int rounds)
|
||||
{
|
||||
Skip.IfNot(LiveSqlServer.IsEnabled, LiveSqlServer.SkipReason);
|
||||
|
||||
@@ -367,10 +378,12 @@ public sealed class SqlServerSecretStoreLiveTests : IAsyncLifetime
|
||||
// 'zbsecrets'") — the retry filter then covered only deadlock 1205. Deliberately NOT the
|
||||
// class's shared schema: that one is already migrated by InitializeAsync, and this race
|
||||
// only exists against a virgin database.
|
||||
for (int round = 0; round < rounds; round++)
|
||||
{
|
||||
string schema = LiveSqlServer.NewSchemaName();
|
||||
try
|
||||
{
|
||||
await Task.WhenAll(Enumerable.Range(0, 4).Select(_ => Task.Run(() =>
|
||||
await Task.WhenAll(Enumerable.Range(0, nodes).Select(_ => Task.Run(() =>
|
||||
new SqlServerSecretsStoreMigrator(
|
||||
new SecretsSqlServerConnectionFactory(LiveSqlServer.OptionsFor(schema)))
|
||||
.MigrateAsync(CancellationToken.None))));
|
||||
@@ -385,6 +398,7 @@ public sealed class SqlServerSecretStoreLiveTests : IAsyncLifetime
|
||||
{
|
||||
await LiveSqlServer.DropSchemaAsync(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user