inject augur and version into engine connection args#3771
Open
inject augur and version into engine connection args#3771
Conversation
based on https://stackoverflow.com/questions/15685861/setting-application-name-on-postgres-sqlalchemy Signed-off-by: Adrian Edwards <[email protected]>
Signed-off-by: Adrian Edwards <[email protected]>
Signed-off-by: Adrian Edwards <[email protected]>
|
|
||
| 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"}) |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0621: Redefining name 'temporary_database_engine' from outer scope (line 44) (redefined-outer-name)
Signed-off-by: Adrian Edwards <[email protected]>
|
|
||
| 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"}) |
There was a problem hiding this comment.
[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"}) |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
E0602: Undefined variable 'version' (undefined-variable)
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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
augurto 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
metadatafile this version is in is not an actual module that is accessibleNotes for Reviewers
Currently testing this in my local dev instance
Signed commits