fix: serialize database activity during playout

This commit is contained in:
2026-07-11 03:43:59 +09:00
parent 8dae7b8e0d
commit f76dbc7272
13 changed files with 327 additions and 46 deletions

View File

@@ -21,8 +21,7 @@ try
foreach (var status in statuses)
{
Console.WriteLine(
$"{status.Source}: {status.State} ({status.Elapsed.TotalMilliseconds:F0} ms) - {status.UserMessage}");
Console.WriteLine(FormatHealthStatus(status));
}
if (statuses.Any(status => status.State != DatabaseHealthState.Healthy))
@@ -49,9 +48,20 @@ catch (OperationCanceledException)
Console.Error.WriteLine("REAL_DB_SMOKE: CANCELED_OR_TIMED_OUT");
return 3;
}
catch (DatabaseInfrastructureException exception)
catch (DatabaseOperationException exception)
{
Console.Error.WriteLine($"REAL_DB_SMOKE: FAIL - {exception.Message}");
Console.Error.WriteLine(
"REAL_DB_SMOKE: FAIL - " +
$"Source={exception.DataSource} " +
$"IsTransient={FormatNullableBoolean(exception.IsTransient)} " +
$"ProviderErrorCode={FormatProviderErrorCode(exception.ProviderErrorCode)}");
return 1;
}
catch (DatabaseInfrastructureException)
{
Console.Error.WriteLine(
"REAL_DB_SMOKE: FAIL - A database infrastructure error occurred. " +
"No provider details were printed.");
return 1;
}
catch
@@ -61,6 +71,32 @@ catch
return 1;
}
static string FormatHealthStatus(DatabaseHealthStatus status)
{
var summary =
$"{status.Source}: {status.State} " +
$"({status.Elapsed.TotalMilliseconds.ToString("F0", CultureInfo.InvariantCulture)} ms)";
if (status.State == DatabaseHealthState.Healthy)
{
return summary;
}
return summary +
$" IsTransient={FormatNullableBoolean(status.IsTransient)}" +
$" ProviderErrorCode={FormatProviderErrorCode(status.ProviderErrorCode)}";
}
static string FormatNullableBoolean(bool? value) => value switch
{
true => "true",
false => "false",
null => "none"
};
static string FormatProviderErrorCode(int? value) =>
value?.ToString(CultureInfo.InvariantCulture) ?? "none";
static string? GetConfigurationPath(string[] arguments)
{
if (arguments.Length == 0)