From 79870333cb3f86fae957285a0a457659bfba9796 Mon Sep 17 00:00:00 2001 From: dailz Date: Wed, 15 Apr 2026 10:27:12 +0800 Subject: [PATCH] fix(service): tolerate concurrent pending-to-uploading status race in UploadChunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When multiple chunk uploads race on the pending→uploading transition, ignore ErrRecordNotFound from UpdateSessionStatus since another request already completed the update. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- internal/service/upload_service.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/service/upload_service.go b/internal/service/upload_service.go index 6ebfbc5..bf6ea25 100644 --- a/internal/service/upload_service.go +++ b/internal/service/upload_service.go @@ -190,7 +190,9 @@ func (s *UploadService) UploadChunk(ctx context.Context, sessionID int64, chunkI if session.Status == "pending" { if err := s.uploadStore.UpdateSessionStatus(ctx, sessionID, "uploading"); err != nil { - return fmt.Errorf("update status to uploading: %w", err) + if !errors.Is(err, gorm.ErrRecordNotFound) { + return fmt.Errorf("update status to uploading: %w", err) + } } }