From 955c3f5e77b4a53d966cb0ee9a96bb34fc0c33d9 Mon Sep 17 00:00:00 2001 From: nns Date: Fri, 9 Oct 2026 14:53:05 +0500 Subject: [PATCH] =?UTF-8?q?fix(migration):=20=D0=BE=D1=87=D0=B8=D1=89?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20ChangeTracker=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B5=20=D0=B4=D0=BE=D0=BA=D1=83?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20(=D1=81=D1=82=D0=BE=D0=BF=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=81=D0=BA=D0=B0=D0=B4=D0=B0=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D0=B5=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Сбой SaveChanges одного документа оставлял сущности tracked → все последующие падали (каскад), импорт застревал. Теперь в catch — ChangeTracker.Clear(). Co-Authored-By: Claude Opus 5.5 --- .../Integrations/MoySklad/MoySkladDocumentImportService.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/food-market.infrastructure/Integrations/MoySklad/MoySkladDocumentImportService.cs b/src/food-market.infrastructure/Integrations/MoySklad/MoySkladDocumentImportService.cs index a7c554a..b4f6614 100644 --- a/src/food-market.infrastructure/Integrations/MoySklad/MoySkladDocumentImportService.cs +++ b/src/food-market.infrastructure/Integrations/MoySklad/MoySkladDocumentImportService.cs @@ -141,6 +141,9 @@ private static DateTime MomentToUtc(string? moment) } catch (Exception ex) { + // Критично: после сбоя SaveChanges очищаем трекер, иначе провалившиеся + // сущности остаются tracked и роняют ВСЕ последующие документы (каскад). + _db.ChangeTracker.Clear(); progress.Errors++; if (progress.ErrorSamples.Count < 20) progress.ErrorSamples.Add($"{d.Name}/{d.Id}: {ex.Message}"); _log.LogWarning(ex, "supply import failed {Id}", d.Id);