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
Copy Markdown
Collaborator

@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
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>

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"})
Copy link
Copy Markdown

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)

Signed-off-by: Adrian Edwards <adredwar@redhat.com>

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"})
Copy link
Copy Markdown

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"})
Copy link
Copy Markdown

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
Copy Markdown
Collaborator

@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
Copy Markdown
Collaborator Author

Screenshot_20260317_145646 can confirm it works


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"})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is __version__ defined or imported anywhere in this file? I don't see it. Wouldn't this raise a NameError at runtime?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh that should probably be removed if it hasn't already. I gave up importing the version except where already available because its in the metadata.py, outside the module structure and therefore hard to properly import

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah! Probably should remove this

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.

3 participants