Skip to content

Persistence: redundant post-commit session.refresh() in create_from_alert (and deploy record) #71

Description

@JumpTechCode

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-480s.add(row)commit()await s.refresh(row) (:479) → return row.id.
  • repositories.py:1326-1359start_run does addflushreturn 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtCode-quality cleanup deferred from a prior PR

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions