fix(db): use engine.begin() to commit cntrb_id updates in update_issue_closed_cntrbs_by_repo_id#3801
Conversation
…e_closed_cntrbs_by_repo_id engine.connect() in SQLAlchemy 2.0 does not autocommit, so the UPDATE setting cntrb_id on issues was silently rolled back on every call. Switching to engine.begin() ensures the transaction is committed, matching the pattern used by every other write operation in this file. Fixes chaoss#3457 Signed-off-by: mn-ram <235066282+mn-ram@users.noreply.github.com>
9d1b9af to
fd36200
Compare
|
im not sure I see the connection between this engine.begin() fix and the issue this PR solves can you go into more detail about how data from two different collection runs ends up in maybe the same transaction so that it can cause a violation of a uniqueness constraint? Also id be curious how its possible to violate a uniqueness constraint without calling |
|
Thanks for the review — you're right on both counts. On the primary fix: On the UniqueViolation: Is there anything else I should address or adjust to get this merged? |
These two statements sound like they contradict each other. I looked at the query immediately below the change you made and it doesnt seem like the update even touches the issue url column at issue here. I will elaborate more in the comments on the issue itself. Can you edit your PR description so it is not linked to the underlying issue? I think this is still a valid change, just not the solution to the underlying issue |
|
Understood — updated the PR description to remove the link to #3457. This is now a standalone correctness fix to align with the existing engine.begin() pattern in lib.py. |
Description
engine.connect()withengine.begin()inupdate_issue_closed_cntrbs_by_repo_idso theUPDATEstatement that setscntrb_idon theissuestable is actually committed.In SQLAlchemy 2.0,
engine.connect()usesautobeginbut does not auto-commit on exit — the transaction is silently rolled back, socntrb_idwas never persisted.engine.begin()commits on a clean exit and rolls back on exception. Every other write inlib.pyalready usesengine.begin()(lines 78, 88, 384, 426) — this was the only outlier.Notes for Reviewers
Standalone correctness fix — aligns this function with the existing
engine.begin()pattern used throughoutlib.py.Signed commits