[EUWE] Set database application name #14909
Merged
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.
This is a manual backport of:
#13856
#14904
https://bugzilla.redhat.com/show_bug.cgi?id=1445928
When we need to do database lock or connection triaging, it's really hard to tell where each connection originated from because we don't specify an application_name. It looks something like this:
vmdb_production=# select pid, application_name from pg_stat_activity;
pid | application_name
------+--------------------------------------------------
13770 | /var/www/miq/vmdb/lib/workers/bin/evm_server.rb
13950 | /var/www/miq/vmdb/lib/workers/bin/evm_server.rb
13957 | /var/www/miq/vmdb/lib/workers/bin/evm_server.rb
13969 | /var/www/miq/vmdb/lib/workers/bin/evm_server.rb
13975 | /var/www/miq/vmdb/lib/workers/bin/evm_server.rb
13984 | /var/www/miq/vmdb/lib/workers/bin/evm_server.rb
The much debated format of the application_name now looks like this:
MIQ [], s[], []
OR:
MIQ Server[], []
Note, the pg backend pid isn't needed in application_name since the pid column in pg_stat_activity is the backend pid. Plus, each of our processes can have more than one spid.
It now looks like this:
vmdb_development=# select pid, application_name from pg_stat_activity;
pid | application_name
------------------+------+-------------+----------------------
5844 | MIQ 5835 Server[1r2], default[1r1]
5888 | MIQ 5886 Generic[1r1111], s[1r2], default[1r1]
5891 | MIQ 5889 Generic[1r1112], s[1r2], default[1r1]
5894 | MIQ 5892 Priority[1r1113], s[1r2], default[1r1]
5897 | MIQ 5895 Priority[1r1114], s[1r2], default[1r1]
5900 | MIQ 5898 Schedule[1r1115], s[1r2], default[1r1]
5928 | MIQ 5926 EventHandler[1r1116], s[1r2], default[1r1]
5932 | MIQ 5929 Reporting[1r1117], s[1r2], default[1r1]
5934 | MIQ 5931 Reporting[1r1118], s[1r2], default[1r1]
5943 | MIQ 5941 Ui[1r1120], s[1r2], default[1r1]
5940 | MIQ 5935 Websocket[1r1119], s[1r2], default[1r1]
5946 | MIQ 5944 WebService[1r1121], s[1r2], default[1r1]
5964 | MIQ 5935 Websocket[1r1119], s[1r2], default[1r1]
5965 | MIQ 5941 Ui[1r1120], s[1r2], default[1r1]
5966 | MIQ 5944 WebService[1r1121], s[1r2], default[1r1]