From 46da2d78f06aec00b21ba7199afa6f3766dff3e4 Mon Sep 17 00:00:00 2001 From: nanxun Date: Fri, 5 Jun 2026 01:01:59 +0800 Subject: [PATCH] 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 --- src/LiveRecorder.WebApi/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LiveRecorder.WebApi/Program.cs b/src/LiveRecorder.WebApi/Program.cs index 33202a7..487917d 100644 --- a/src/LiveRecorder.WebApi/Program.cs +++ b/src/LiveRecorder.WebApi/Program.cs @@ -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(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); }));