Skip to content

[Operating] allow to identify DB connection "owner"#1261

Merged
FlorianSW merged 1 commit intomasterfrom
ops/identify_connections
Apr 7, 2026
Merged

[Operating] allow to identify DB connection "owner"#1261
FlorianSW merged 1 commit intomasterfrom
ops/identify_connections

Conversation

@FlorianSW
Copy link
Copy Markdown
Collaborator

When having several different services running as part of a CRCon setup, and trying to identify what component/service is using a particular amount/number of DB connections is hard, apart from telling the total number of open connections.

This commit aims to solve this issue by providing a proper identification for a DB connection. It is composed out of the name of the component that initiated the connection (e.g. gunicorn for the API backend, auto_settings for the autosettings component, etc) together with the server number.

The name is inferred from the application start commands to keep the API for using the DB layer in the CRCon stable and to not bother callers to provide any identification. If a component name cannot be inferred, a generic "CRCon Generic" name is used.

The connection name will show up as the "application_name" in the pg_stat_activity table of postgres, which can be quried with: select * from pg_stat_activity;

When having several different services running as part of a CRCon setup,
and trying to identify what component/service is using a particular
amount/number of DB connections is hard, apart from telling the total
number of open connections.

This commit aims to solve this issue by providing a proper
identification for a DB connection. It is composed out of the name of
the component that initiated the connection (e.g. gunicorn for the API
backend, auto_settings for the autosettings component, etc) together
with the server number.

The name is inferred from the application start commands to keep the API
for using the DB layer in the CRCon stable and to not bother callers to
provide any identification. If a component name cannot be inferred, a
generic "CRCon Generic" name is used.

The connection name will show up as the "application_name" in the
pg_stat_activity table of postgres, which can be quried with:
select * from pg_stat_activity;
@FlorianSW
Copy link
Copy Markdown
Collaborator Author

This will look something like this (not all services are started, though):
image

Copy link
Copy Markdown
Collaborator

@Fragger Fragger left a comment

Choose a reason for hiding this comment

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

Ran this and it all seems to work, will be good info have.

@FlorianSW FlorianSW merged commit eb9d8b5 into master Apr 7, 2026
3 checks passed
@FlorianSW FlorianSW deleted the ops/identify_connections branch April 7, 2026 13:16
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