-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set database_application_name in workers and server.
Previously, pg_stat_activity would look 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 ``` 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] ```
- Loading branch information
Showing
8 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module ArApplicationName | ||
# We need to set the PGAPPNAME env variable and force the 'pg' gem objects to be | ||
# recreated with this env variable set. This is done by disconnecting all of the | ||
# connections in the pool. We do this because reconnect! on an instance of the | ||
# AR adapter created prior to our change to PGAPPNAME will have old connection | ||
# options, which will reset our application_name. | ||
# | ||
# Because we fork workers from the server, if we don't disconnect the pool, | ||
# any call to reconnect! on a connection will cause the worker's connection | ||
# to have the server's application_name. | ||
def self.name=(name) | ||
# TODO: this is postgresql specific | ||
ENV['PGAPPNAME'] = name | ||
ActiveRecord::Base.connection_pool.disconnect! | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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