From 72489c73dfec6d073f3135299a0ff207f6d2689e Mon Sep 17 00:00:00 2001 From: dv Date: Wed, 8 Apr 2026 00:23:09 +0300 Subject: [PATCH] fix ssh 6 --- backend/app/services/device_discovery.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/app/services/device_discovery.py b/backend/app/services/device_discovery.py index 24aa85c..443bf81 100644 --- a/backend/app/services/device_discovery.py +++ b/backend/app/services/device_discovery.py @@ -433,4 +433,13 @@ async def discover_via_ssh( except Exception as exc: result.errors.append(f"Error upserting {found.ip}: {exc}") + # Flush after each rack so that subsequent SELECTs (for other racks + # that may share the same device IPs) see the just-added rows. + # Without this, autoflush=False means pending db.add() calls are + # invisible to SELECT queries, causing UniqueViolationError on flush. + try: + await db.flush() + except Exception as exc: + result.errors.append(f"Flush error after rack {rack_host}: {exc}") + return result