Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #982 from joyent/ether/v2-db-application_name
Browse files Browse the repository at this point in the history
use the current pid, not the starting application's pid, in application_name
  • Loading branch information
karenetheridge authored Feb 3, 2020
2 parents 281f852 + 2e9b3d2 commit 88e6e29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Conch/Plugin/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ that persists for the lifetime of the application.
my $_rw_schema;
$app->helper(schema => sub ($c) {
return $_rw_schema if $_rw_schema;
my $app_name = $c->app->moniker.'-'.$c->version_tag.' ('.$$.')';
my $app_name = $c->app->moniker.'-'.$c->version_tag;
$_rw_schema = Conch::DB->connect(
$db_credentials->@{qw(dsn username password)},
+{
$db_credentials->{options}->%*,
on_connect_do => [ q{set application_name to '}.$app_name.q{'} ],
on_connect_do => [ sub {[q{set application_name to '}.$app_name.q{ (}.$$.q{)'}]} ],
},
);
});
Expand Down Expand Up @@ -82,14 +82,14 @@ cleared with C<< ->txn_rollback >>; see L<DBD::Pg/"ReadOnly-(boolean)">.
# see L<DBIx::Class::Storage::DBI/DBIx::Class and AutoCommit>
local $ENV{DBIC_UNSAFE_AUTOCOMMIT_OK} = 1;
return $_ro_schema if $_ro_schema;
my $app_name = $c->app->moniker.'-'.$c->version_tag.' ('.$$.')';
my $app_name = $c->app->moniker.'-'.$c->version_tag;
$_ro_schema = Conch::DB->connect(
$db_credentials->@{qw(dsn ro_username ro_password)},
+{
$db_credentials->{options}->%*,
ReadOnly => 1,
AutoCommit => 0,
on_connect_do => [ q{set application_name to '}.$app_name.q{'} ],
on_connect_do => [ sub {[q{set application_name to '}.$app_name.q{ (}.$$.q{)'}]} ],
},
);
$c->stash('ro_schema', $_ro_schema);
Expand Down

0 comments on commit 88e6e29

Please sign in to comment.