[open-ils-commits] [GIT] Evergreen ILS branch master updated. b8eb0b6376e85fe99eddc0999cc86d83ce922aef
Evergreen Git
git at git.evergreen-ils.org
Wed Mar 2 15:58:43 EST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via b8eb0b6376e85fe99eddc0999cc86d83ce922aef (commit)
via efb194d70a1560f436e328f35924df0be52e2431 (commit)
via f9421938ec6be6a023fd72b75f052af9c48ae606 (commit)
from 524a3dc3713745ed22966446b97a302cd1593eed (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b8eb0b6376e85fe99eddc0999cc86d83ce922aef
Author: Galen Charlton <gmc at esilibrary.com>
Date: Tue Feb 16 15:47:47 2016 -0500
LP#1492793: add release notes
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/DB_Application_Name_Option.adoc b/docs/RELEASE_NOTES_NEXT/Administration/DB_Application_Name_Option.adoc
new file mode 100644
index 0000000..640fa96
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/Administration/DB_Application_Name_Option.adoc
@@ -0,0 +1,8 @@
+Set application name when connecting to database
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The services that connect directly to the PostgreSQL database
+(and Clark Kent) now look for an application_name parameter
+as part of the database login credentials specified in
+`opensrf.xml`. If present, the value is used to set the
+application name Pg connection value; this in turn shows up in
+the Postgres `pg_stat_activity` table and Pg's logs.
commit efb194d70a1560f436e328f35924df0be52e2431
Author: Galen Charlton <gmc at esilibrary.com>
Date: Tue Feb 16 15:36:26 2016 -0500
LP#1492793: teach Clark Kent to set the Pg app name
Clark Kent can now also use the application_name
setting in the relevant sections of opensrf.xml to
set the Pg application name.
To test:
[1] Apply the patch, restarting opensrf.settings, and
start Clark.
[2] Run a report that will take at least a minute to
finish. While it is running, query the pg_stat_activity
table. There should be at least one row where the
application_name column is set to 'Clark Kent (reports)'.
[3] Note that since the master Clark process opens a database
connection, checks whether there are any reports to run,
then immediately closes the connection, it's unlikely that
you'll catch a 'Clark Kent (state)' connection when
querying pg_stat_activity.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example
index 7b6484c..87db4cc 100644
--- a/Open-ILS/examples/opensrf.xml.example
+++ b/Open-ILS/examples/opensrf.xml.example
@@ -159,7 +159,7 @@ vim:et:ts=4:sw=4:
<db>evergreen</db>
<user>postgres</user>
<pw>postgres</pw>
- <application_name>open-ils.reporter</application_name>
+ <application_name>Clark Kent (reports)</application_name>
</database>
<state_store>
<driver>Pg</driver>
@@ -168,7 +168,7 @@ vim:et:ts=4:sw=4:
<db>evergreen</db>
<user>postgres</user>
<pw>postgres</pw>
- <application_name>open-ils.reporter-state</application_name>
+ <application_name>Clark Kent (state)</application_name>
</state_store>
<files>
<!-- successful report outputs go here -->
diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl
index fabd2db..9fbf602 100755
--- a/Open-ILS/src/reporter/clark-kent.pl
+++ b/Open-ILS/src/reporter/clark-kent.pl
@@ -67,6 +67,7 @@ if (!$data_db{db_name}) {
}
$data_db{db_user} = $sc->config_value( reporter => setup => database => 'user' );
$data_db{db_pw} = $sc->config_value( reporter => setup => database => 'pw' );
+$data_db{db_app} = $sc->config_value( reporter => setup => database => 'application_name' );
@@ -80,6 +81,8 @@ if (!$state_db{db_name}) {
}
$state_db{db_user} = $sc->config_value( reporter => setup => state_store => 'user' ) || $data_db{db_user};
$state_db{db_pw} = $sc->config_value( reporter => setup => state_store => 'pw' ) || $data_db{db_pw};
+$state_db{db_app} = $sc->config_value( reporter => setup => state_store => 'application_name' )
+ || $data_db{db_app};
die "Unable to retrieve database connection information from the settings server"
@@ -94,7 +97,9 @@ my $output_base = $sc->config_value( reporter => setup => files => 'output_
my $base_uri = $sc->config_value( reporter => setup => 'base_uri' );
my $state_dsn = "dbi:" . $state_db{db_driver} . ":dbname=" . $state_db{db_name} .';host=' . $state_db{db_host} . ';port=' . $state_db{db_port};
+$state_dsn .= ";application_name='$state_db{db_app}'" if $state_db{db_app};
my $data_dsn = "dbi:" . $data_db{db_driver} . ":dbname=" . $data_db{db_name} .';host=' . $data_db{db_host} . ';port=' . $data_db{db_port};
+$data_dsn .= ";application_name='$data_db{db_app}'" if $data_db{db_app};
my $count = $opt_count //
$sc->config_value( reporter => setup => 'parallel' ) //
commit f9421938ec6be6a023fd72b75f052af9c48ae606
Author: Jason Boyer <jboyer at library.in.gov>
Date: Sun Sep 6 12:58:49 2015 -0400
LP1492793: Support Application Name Postgres Option
If app_settings/database/application_name is defined,
connections by that service will have the application_name
postgres option set, allowing log analyzers to associate
queries and services.
To test:
[1] Apply the patch and restart OpenSRF services.
[2] Query the pg_stat_activity table in the PostgreSQL
database; the application_name column should now
be populated with values like 'open-ils.cstore'
or 'open-ils.storage' that indicate which Evergreen
service holds the database connection.
Signed-off-by: Jason Boyer <jboyer at library.in.gov>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example
index 59f737a..7b6484c 100644
--- a/Open-ILS/examples/opensrf.xml.example
+++ b/Open-ILS/examples/opensrf.xml.example
@@ -159,6 +159,7 @@ vim:et:ts=4:sw=4:
<db>evergreen</db>
<user>postgres</user>
<pw>postgres</pw>
+ <application_name>open-ils.reporter</application_name>
</database>
<state_store>
<driver>Pg</driver>
@@ -167,6 +168,7 @@ vim:et:ts=4:sw=4:
<db>evergreen</db>
<user>postgres</user>
<pw>postgres</pw>
+ <application_name>open-ils.reporter-state</application_name>
</state_store>
<files>
<!-- successful report outputs go here -->
@@ -880,6 +882,7 @@ vim:et:ts=4:sw=4:
<pw>postgres</pw>
<db>evergreen</db>
<client_encoding>UTF-8</client_encoding>
+ <application_name>open-ils.storage</application_name>
</database>
</databases>
</app_settings>
@@ -909,6 +912,7 @@ vim:et:ts=4:sw=4:
<pw>postgres</pw>
<db>evergreen</db>
<client_encoding>UTF-8</client_encoding>
+ <application_name>open-ils.cstore</application_name>
</database>
</app_settings>
</open-ils.cstore>
@@ -943,6 +947,7 @@ vim:et:ts=4:sw=4:
<pw>postgres</pw>
<db>evergreen</db>
<client_encoding>UTF-8</client_encoding>
+ <application_name>open-ils.pcrud</application_name>
</database>
</app_settings>
</open-ils.pcrud>
@@ -970,6 +975,7 @@ vim:et:ts=4:sw=4:
<pw>postgres</pw>
<db>evergreen</db>
<client_encoding>UTF-8</client_encoding>
+ <application_name>open-ils.qstore</application_name>
</database>
</app_settings>
</open-ils.qstore>
@@ -1055,6 +1061,7 @@ vim:et:ts=4:sw=4:
<pw>postgres</pw>
<db>evergreen</db>
<client_encoding>UTF-8</client_encoding>
+ <application_name>open-ils.reporter-store</application_name>
</database>
</app_settings>
</open-ils.reporter-store>
diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c
index 8169f42..bacb867 100644
--- a/Open-ILS/src/c-apps/oils_sql.c
+++ b/Open-ILS/src/c-apps/oils_sql.c
@@ -167,6 +167,7 @@ dbi_conn oilsConnectDB( const char* mod_name ) {
char* port = osrf_settings_host_value( "/apps/%s/app_settings/database/port", mod_name );
char* db = osrf_settings_host_value( "/apps/%s/app_settings/database/db", mod_name );
char* pw = osrf_settings_host_value( "/apps/%s/app_settings/database/pw", mod_name );
+ char* pg_app = osrf_settings_host_value( "/apps/%s/app_settings/database/application_name", mod_name );
osrfLogDebug( OSRF_LOG_MARK, "Attempting to load the database driver [%s]...", driver );
dbi_conn handle = dbi_conn_new( driver );
@@ -180,17 +181,19 @@ dbi_conn oilsConnectDB( const char* mod_name ) {
osrfLogInfo(OSRF_LOG_MARK, "%s connecting to database. host=%s, "
"port=%s, user=%s, db=%s", mod_name, host, port, user, db );
- if( host ) dbi_conn_set_option( handle, "host", host );
- if( port ) dbi_conn_set_option_numeric( handle, "port", atoi( port ));
- if( user ) dbi_conn_set_option( handle, "username", user );
- if( pw ) dbi_conn_set_option( handle, "password", pw );
- if( db ) dbi_conn_set_option( handle, "dbname", db );
+ if( host ) dbi_conn_set_option( handle, "host", host );
+ if( port ) dbi_conn_set_option_numeric( handle, "port", atoi( port ));
+ if( user ) dbi_conn_set_option( handle, "username", user );
+ if( pw ) dbi_conn_set_option( handle, "password", pw );
+ if( db ) dbi_conn_set_option( handle, "dbname", db );
+ if( pg_app ) dbi_conn_set_option( handle, "pgsql_application_name", pg_app );
free( user );
free( host );
free( port );
free( db );
free( pw );
+ free( pg_app );
if( dbi_conn_connect( handle ) < 0 ) {
sleep( 1 );
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm
index a3e360b..3a64595 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm
@@ -71,7 +71,8 @@
"dbi:Pg:".
"host=$$master{host};".
"port=$$master{port};".
- "dbname=$$master{db}",
+ "dbname=$$master{db}".
+ ($$master{application_name} ? ";application_name='$$master{application_name}'": ""),
$$master{user},
$$master{pw},
\%attrs)
@@ -80,7 +81,8 @@
"dbi:Pg:".
"host=$$master{host};".
"port=$$master{port};".
- "dbname=$$master{db}",
+ "dbname=$$master{db}".
+ ($$master{application_name} ? ";application_name='$$master{application_name}'": ""),
$$master{user},
$$master{pw},
\%attrs) }
@@ -100,8 +102,8 @@
for my $db (@$_db_params) {
try {
- push @slave_dbs, DBI->connect("dbi:Pg:host=$$db{host};port=$$db{port};dbname=$$db{db}",$$db{user},$$db{pw}, \%attrs)
- || do { sleep(1); DBI->connect("dbi:Pg:host=$$db{host};port=$$db{port};dbname=$$db{db}",$$db{user},$$db{pw}, \%attrs) }
+ push @slave_dbs, DBI->connect("dbi:Pg:host=$$db{host};port=$$db{port};dbname=$$db{db}". ($$db{application_name} ? ";application_name='$$db{application_name}'" : ""),$$db{user},$$db{pw}, \%attrs)
+ || do { sleep(1); DBI->connect("dbi:Pg:host=$$db{host};port=$$db{port};dbname=$$db{db}". ($$db{application_name} ? ";application_name='$$db{application_name}'" : ""),$$db{user},$$db{pw}, \%attrs) }
|| throw OpenSRF::EX::ERROR
("Couldn't connect to $$db{db}".
" on $$db{host}::$$db{port}".
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/examples/opensrf.xml.example | 7 +++++++
Open-ILS/src/c-apps/oils_sql.c | 13 ++++++++-----
.../lib/OpenILS/Application/Storage/Driver/Pg.pm | 10 ++++++----
Open-ILS/src/reporter/clark-kent.pl | 5 +++++
.../Administration/DB_Application_Name_Option.adoc | 8 ++++++++
5 files changed, 34 insertions(+), 9 deletions(-)
create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/DB_Application_Name_Option.adoc
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list