From 070aa329febebfcf4807f94e13f5bfa1bc623a44 Mon Sep 17 00:00:00 2001 From: claude Date: Mon, 1 Jun 2026 16:16:54 +0300 Subject: [PATCH] Add warning log for duplicate key violations in SaveMatchAsync When a match result is inserted concurrently between the existence check and the database insert, log a warning to help with diagnostics while gracefully handling the idempotent duplicate key violation. --- Apis/cv-matcher-data/Repositories/EfMatcherRepository.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Apis/cv-matcher-data/Repositories/EfMatcherRepository.cs b/Apis/cv-matcher-data/Repositories/EfMatcherRepository.cs index 504fd0c..651dcea 100644 --- a/Apis/cv-matcher-data/Repositories/EfMatcherRepository.cs +++ b/Apis/cv-matcher-data/Repositories/EfMatcherRepository.cs @@ -68,6 +68,10 @@ public sealed class EfMatcherRepository : IMatcherRepository { // Duplicate key violation: record was inserted between the AnyAsync check and SaveChangesAsync. // This is safe to ignore — the match result already exists in the database. + _logger.LogWarning( + "Duplicate match result ignored: CV={CvDocumentId} Job={JobDocumentId} Language={Language}. " + + "Record was likely inserted concurrently. This is expected behavior in high-concurrency scenarios.", + cvDocumentId, jobDocumentId, language); } }