Skip to content

Commit

Permalink
revert: keep retry logic until pooling error is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Apr 3, 2024
1 parent 1f91a9b commit 94d950a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions insights/insights/doctype/insights_data_source/sources/mariadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from sqlalchemy import table as Table
from sqlalchemy import text
from sqlalchemy.engine.base import Connection
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

from insights.insights.query_builders.sql_builder import SQLQueryBuilder

Expand Down Expand Up @@ -108,6 +109,15 @@ def __init__(self, data_source, host, port, username, password, database_name, u
self.query_builder: SQLQueryBuilder = SQLQueryBuilder(self.engine)
self.table_factory: MariaDBTableFactory = MariaDBTableFactory(data_source)

@retry(
retry=retry_if_exception_type((DatabaseParallelConnectionError,)),
stop=stop_after_attempt(3),
wait=wait_fixed(1),
reraise=True,
)
def connect(self, *args, **kwargs):
return super().connect(*args, **kwargs)

def handle_db_connection_error(self, e):
if "Access denied" in str(e):
raise DatabaseCredentialsError()
Expand Down

0 comments on commit 94d950a

Please sign in to comment.