Skip to content

inject augur and version into engine connection args#3771

Open
MoralCode wants to merge 4 commits intomainfrom
qol/postgres_name
Open

inject augur and version into engine connection args#3771
MoralCode wants to merge 4 commits intomainfrom
qol/postgres_name

Conversation

@MoralCode
Copy link
Contributor

@MoralCode MoralCode commented Mar 16, 2026

When diagnosing #3770, i investigated the seemingly high number of idle postgres tasks. while confirming whether these were a problem, i used dbeaver to view the open sessions on the database. This view in dbeaver has a column for application name (a couple of which were populated with dbeavers own name, for its own db connections).

I think setting augur to identify its own connections this way ( which can be done using https://stackoverflow.com/questions/15685861/setting-application-name-on-postgres-sqlalchemy) is a small change that can would help debugging efforts, especially when multiple things (grafana stack, augur, dbeaver or other user-preferred database tools, researchers) can be accessing an augur database at a time. This may also lightly help debug our "connection leaks" issue (#3452 etc)

This PR adds the string augur to this field by passing it as a connection argument when we create a database engine.

This string may also be followed by some other text indicating which part of augur the database connections are coming from (such as api, cli, etc). While I initially tried to include the version number, This turned out to not be possible as testing revealed that the metadata file this version is in is not an actual module that is accessible

Notes for Reviewers
Currently testing this in my local dev instance

Signed commits

  • Yes, I signed my commits.

@MoralCode MoralCode added this to the v0.94.0 milestone Mar 16, 2026
@MoralCode MoralCode requested a review from sgoggins as a code owner March 16, 2026 18:55

url = get_database_string()
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool)
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool, connect_args={"application_name": f"augur v{__version__} temporary"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'temporary_database_engine' from outer scope (line 44) (redefined-outer-name)


url = get_database_string()
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool)
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool, connect_args={"application_name": f"augur v{__version__} temporary"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'temporary_database_engine' from outer scope (line 42) (redefined-outer-name)


url = get_database_string()
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool)
temporary_database_engine = create_database_engine(url=url, poolclass=StaticPool, connect_args={"application_name": f"augur v{__version__} temporary"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'version' (undefined-variable)

@sgoggins sgoggins self-assigned this Mar 17, 2026
Copy link
Member

@sgoggins sgoggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MoralCode
Copy link
Contributor Author

Screenshot_20260317_145646 can confirm it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants