Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection ping bug #33

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/modules/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def cursor(self, cursorclass=None):
def ping(self):
if not self._conn:
self._conn = self.connect()
self._conn.ping()
try:
self._conn.ping()
except OperationalError:
self._conn = self.connect()

def close(self):
if self._conn:
Expand Down Expand Up @@ -104,10 +107,7 @@ def get_connection(self):

yield conn

try:
conn.ping()
except OperationalError:
conn = Connection(self.endpoint)
conn.ping()
if self.free_connections.full():
raise Exception("Connection pool full")
else:
Expand Down
8 changes: 4 additions & 4 deletions src/sbosc/controller/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def __validate_bulk_import_batch(self, range_queue: Queue, failed_pks):
return False
except MySQLdb.OperationalError as e:
self.__handle_operational_error(e, range_queue, batch_start_pk, batch_end_pk)
source_conn.ping(True)
dest_conn.ping(True)
source_conn.ping()
dest_conn.ping()
continue
except Empty:
self.logger.warning("Range queue is empty")
Expand Down Expand Up @@ -226,8 +226,8 @@ def __validate_apply_dml_events_batch(self, table, range_queue: Queue, unmatched
)
except MySQLdb.OperationalError as e:
self.__handle_operational_error(e, range_queue, batch_start_timestamp, batch_end_timestamp)
source_conn.ping(True)
dest_conn.ping(True)
source_conn.ping()
dest_conn.ping()
continue

def __validate_unmatched_pks(self):
Expand Down
Loading