From 93d98767aad5a76dfaf6e8da06cc25facb5f7f6d Mon Sep 17 00:00:00 2001 From: devs6186 Date: Thu, 19 Feb 2026 02:09:01 +0530 Subject: [PATCH 1/2] [tasks/github] Fix uncommitted UPDATE in update_issue_closed_cntrbs_by_repo_id Fixes #3457 - Replace engine.connect() with engine.begin() so the UPDATE on issues.cntrb_id is actually committed; previously every call was silently rolled back at context-manager exit in SQLAlchemy 2.0 - Wrap the call site in events.py with try/except so a transient DB error here does not abort the entire batch of event collection Signed-off-by: devs6186 Signed-off-by: Adrian Edwards --- augur/application/db/lib.py | 5 ++++- augur/tasks/github/events.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/augur/application/db/lib.py b/augur/application/db/lib.py index d0a5972e5f..f6ebbdbc9d 100644 --- a/augur/application/db/lib.py +++ b/augur/application/db/lib.py @@ -560,7 +560,10 @@ def update_issue_closed_cntrbs_by_repo_id(repo_id): ) if update_data: - with engine.connect() as connection: + # engine.begin() auto-commits (or rolls back on exception). + # engine.connect() does NOT auto-commit, so the UPDATE was previously + # silently rolled back on every call (issue #3457). + with engine.begin() as connection: update_stmt = s.text(""" UPDATE issues SET cntrb_id = :cntrb_id diff --git a/augur/tasks/github/events.py b/augur/tasks/github/events.py index a2a8736c8a..48ae0d2555 100644 --- a/augur/tasks/github/events.py +++ b/augur/tasks/github/events.py @@ -167,7 +167,10 @@ def _process_events(self, events, repo_id): self._process_issue_events(issue_events, repo_id) self._process_pr_events(pr_events, repo_id) - update_issue_closed_cntrbs_by_repo_id(repo_id) + try: + update_issue_closed_cntrbs_by_repo_id(repo_id) + except Exception as e: + self._logger.error(f"{self.repo_identifier} - {self.task_name}: Failed to update issue closed contributors: {e}") def _process_issue_events(self, issue_events, repo_id): From b9eb8de36975d743eca6e8baf6c127f7422dac74 Mon Sep 17 00:00:00 2001 From: Adrian Edwards Date: Mon, 16 Mar 2026 16:41:27 -0400 Subject: [PATCH 2/2] find and replace engine.connect() with engine.begin() in places we actually perform updates to data Signed-off-by: Adrian Edwards --- augur/application/cli/collection.py | 2 +- augur/application/cli/github.py | 2 +- augur/tasks/data_analysis/insight_worker/tasks.py | 12 ++++++------ augur/tasks/github/events.py | 4 ++-- augur/tasks/github/messages.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/augur/application/cli/collection.py b/augur/application/cli/collection.py index 810fecf74a..3ff8d07d32 100644 --- a/augur/application/cli/collection.py +++ b/augur/application/cli/collection.py @@ -200,7 +200,7 @@ def repo_reset(ctx): """ Refresh repo collection to force data collection """ - with ctx.obj.engine.connect() as connection: + with ctx.obj.engine.begin() as connection: connection.execute(s.sql.text(""" UPDATE augur_operations.collection_status SET core_status='Pending',core_task_id = NULL, core_data_last_collected = NULL; diff --git a/augur/application/cli/github.py b/augur/application/cli/github.py index 0fa1f2967c..5e696d5188 100644 --- a/augur/application/cli/github.py +++ b/augur/application/cli/github.py @@ -26,7 +26,7 @@ def update_api_key(): Get the ratelimit of Github API keys """ - with DatabaseEngine() as engine, engine.connect() as connection: + with DatabaseEngine() as engine, engine.begin() as connection: get_api_keys_sql = s.sql.text( """ diff --git a/augur/tasks/data_analysis/insight_worker/tasks.py b/augur/tasks/data_analysis/insight_worker/tasks.py index 97a6580d6f..0070d7910f 100644 --- a/augur/tasks/data_analysis/insight_worker/tasks.py +++ b/augur/tasks/data_analysis/insight_worker/tasks.py @@ -106,7 +106,7 @@ def insight_model(repo_git: str,logger,engine) -> None: AND ri_date < :min_date """) - with engine.connect() as conn: + with engine.begin() as conn: result = conn.execute(delete_record_SQL, parameters=dict(repo_id=repo_id, min_date=min_date)) logger.info("Deleting out of date data points ...\n") @@ -128,7 +128,7 @@ def insight_model(repo_git: str,logger,engine) -> None: AND repo_insights.ri_field = to_delete.ri_field """) - with engine.connect() as conn: + with engine.begin() as conn: result = conn.execute(delete_points_SQL, parameters=dict(repo_id=repo_id, min_date=min_date)) # get table values to check for dupes later on @@ -561,7 +561,7 @@ def clear_insights(repo_id, new_endpoint, new_field, logger): AND ri_field = '{}' """.format(repo_id, new_endpoint, new_field) try: - with engine.connect() as conn: + with engine.begin() as conn: result = conn.execute(deleteSQL) except Exception as e: logger.info("Error occured deleting insight slot: {}".format(e)) @@ -579,7 +579,7 @@ def clear_insights(repo_id, new_endpoint, new_field, logger): AND ri_field = '{}' """.format(repo_id, new_endpoint, new_field) try: - with engine.connect() as conn: + with engine.begin() as conn: result = conn.execute(deleteSQL) except Exception as e: logger.info("Error occured deleting insight slot: {}".format(e)) @@ -622,7 +622,7 @@ def clear_insight(repo_id, new_score, new_metric, new_field, logger): AND ri_field = '{}' """.format(record['repo_id'], record['ri_metric'], record['ri_field']) try: - with engine.connect() as conn: + with engine.begin() as conn: result = conn.execute(deleteSQL) except Exception as e: logger.info("Error occured deleting insight slot: {}".format(e)) @@ -676,7 +676,7 @@ def clear_insight(repo_id, new_score, new_metric, new_field, logger): AND ri_metric = '{}' """.format(insight['repo_id'], insight['ri_metric']) try: - with engine.connect() as conn: + with engine.begin() as conn: result = conn.execute(deleteSQL) except Exception as e: logger.info("Error occured deleting insight slot: {}".format(e)) diff --git a/augur/tasks/github/events.py b/augur/tasks/github/events.py index 48ae0d2555..90825ce893 100644 --- a/augur/tasks/github/events.py +++ b/augur/tasks/github/events.py @@ -287,7 +287,7 @@ def _collect_and_process_issue_events(self, owner, repo, repo_id, key_auth, sinc engine = get_engine() - with engine.connect() as connection: + with engine.begin() as connection: if since: # TODO: Remove src id if it ends up not being needed @@ -352,7 +352,7 @@ def _collect_and_process_pr_events(self, owner, repo, repo_id, key_auth, since): engine = get_engine() - with engine.connect() as connection: + with engine.begin() as connection: if since: query = text(f""" diff --git a/augur/tasks/github/messages.py b/augur/tasks/github/messages.py index e8453a18df..bb0807df3b 100644 --- a/augur/tasks/github/messages.py +++ b/augur/tasks/github/messages.py @@ -93,7 +93,7 @@ def process_large_issue_and_pr_message_collection(repo_id, repo_git: str, logger engine = get_engine() - with engine.connect() as connection: + with engine.begin() as connection: if since: query = text(f"""