Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: Add proper error handling for database reconnection attempts (#12650)

Mohan0a8eb11c3db2
diff --git a/api/db/db_models.py b/api/db/db_models.py
index 080613b84c..cdd986c48e 100644
--- a/api/db/db_models.py
+++ b/api/db/db_models.py
@@ -281,7 +281,11 @@ class RetryingPooledMySQLDatabase(PooledMySQLDatabase):
except Exception as e:
logging.error(f"Failed to reconnect: {e}")
time.sleep(0.1)
- self.connect()
+ try:
+ self.connect()
+ except Exception as e2:
+ logging.error(f"Failed to reconnect on second attempt: {e2}")
+ raise
def begin(self):
for attempt in range(self.max_retries + 1):
@@ -352,7 +356,11 @@ class RetryingPooledPostgresqlDatabase(PooledPostgresqlDatabase):
except Exception as e:
logging.error(f"Failed to reconnect to PostgreSQL: {e}")
time.sleep(0.1)
- self.connect()
+ try:
+ self.connect()
+ except Exception as e2:
+ logging.error(f"Failed to reconnect to PostgreSQL on second attempt: {e2}")
+ raise
def begin(self):
for attempt in range(self.max_retries + 1):