From 46577fede07b4c40d276c583d9175a47a61152ec Mon Sep 17 00:00:00 2001
From: Thomas Ives <tri@observatorysciences.co.uk>
Date: Tue, 17 Mar 2026 16:12:49 +0000
Subject: [PATCH] DbConnection::reconnect: Don't mark as disconnected on
 failure

If the connection is marked as disconnected then we do not attempt to
use the connection, however, we don't want to stop using the connection
object just because a reconnect() failed.
---
 src/DbConnection.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/DbConnection.cpp b/src/DbConnection.cpp
index f7975bf..5414b7d 100644
--- a/src/DbConnection.cpp
+++ b/src/DbConnection.cpp
@@ -173,7 +173,17 @@ void DbConnection::reconnect()
 {
     spdlog::debug("Initiating reconnection to the postgres database");
     disconnect();
-    connect(_connection_string);
+    try
+    {
+        connect(_connection_string);
+    }
+    catch(...)
+    {
+        // we don't want to stop using this connection, just because we failed
+        // to connect.
+        _connected = true;
+        throw;
+    }
 }
 
 //=============================================================================
-- 
2.53.0

