Summary
create_from_alert issues a redundant SELECT via session.refresh() after commit, even though expire_on_commit=False + RETURNING already populate the server-default UUID PK at flush time. The project's own start_run does this correctly (flush, no refresh).
Evidence
sentinel/persistence/repositories.py:466-480 — s.add(row) → commit() → await s.refresh(row) (:479) → return row.id.
repositories.py:1326-1359 — start_run does add → flush → return row.id, with a comment noting flush populates row.id via RETURNING. No refresh.
- Same redundant pattern in
PostgresDeployRepository.record (repositories.py:964-988).
Fix
Drop the post-commit refresh() (use flush if the PK is needed pre-commit), matching start_run.
Summary
create_from_alertissues a redundantSELECTviasession.refresh()after commit, even thoughexpire_on_commit=False+RETURNINGalready populate the server-default UUID PK at flush time. The project's ownstart_rundoes this correctly (flush, no refresh).Evidence
sentinel/persistence/repositories.py:466-480—s.add(row)→commit()→await s.refresh(row)(:479) →return row.id.repositories.py:1326-1359—start_rundoesadd→flush→return row.id, with a comment noting flush populatesrow.idvia RETURNING. No refresh.PostgresDeployRepository.record(repositories.py:964-988).Fix
Drop the post-commit
refresh()(useflushif the PK is needed pre-commit), matchingstart_run.