forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#13856 from jrafanie/set_database_applicat…
…ion_name Set database application name in workers and server (cherry picked from commit f241df4)
- Loading branch information
Showing
7 changed files
with
59 additions
and
5 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
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