perf: increase DB timeout to 120s, reduce retries to 3 with longer delay

Raspberry Pi PostgreSQL is I/O constrained. 60s timeout was too short
for concurrent writes during heavy recording sessions, causing timeout +
retry causing duplicate key violations.

- CommandTimeout: 60s -> 120s
- maxRetryCount: 5 -> 3
- maxRetryDelay: 10s -> 15s

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
This commit is contained in:
2026-06-05 01:01:59 +08:00
co-authored by Claude Opus 4.8 noreply@anthropic.com
parent 524a053263
commit 46da2d78f0
+3 -3
View File
@@ -132,7 +132,7 @@ if (connectionStringBuilder.Timeout <= 0)
if (connectionStringBuilder.CommandTimeout <= 0)
{
connectionStringBuilder.CommandTimeout = 60;
connectionStringBuilder.CommandTimeout = 120;
}
if (connectionStringBuilder.KeepAlive <= 0)
@@ -146,8 +146,8 @@ builder.Services.AddDbContext<LiveRecorderDbContext>(options =>
npgsql.MigrationsAssembly(typeof(LiveRecorderDbContext).Assembly.FullName);
npgsql.CommandTimeout(connectionStringBuilder.CommandTimeout);
npgsql.EnableRetryOnFailure(
maxRetryCount: 5,
maxRetryDelay: TimeSpan.FromSeconds(10),
maxRetryCount: 3,
maxRetryDelay: TimeSpan.FromSeconds(15),
errorCodesToAdd: null);
}));