From: Galen Charlton Date: Fri, 20 Mar 2015 20:55:22 +0000 (+0000) Subject: set a limit on how long a Clark Kent query can run X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=82f146f93bfafa88fd1ccf25a11e35b1cf919e47;p=working%2FEvergreen.git set a limit on how long a Clark Kent query can run Reporter queries that take too long to run are very often simply malformed, and in extreme cases can chew through a lot of temp disk space on PostgreSQL servers. To avoid this, Clark Kent by defaults only allows a query to run for up to 10 minutes by setting a local statement timeout. The value of the timeout can be tweaked by setting the a new command-line option for clark-kent.pl, --statement-timeout. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index f2e40565ba..3821011fd8 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -34,12 +34,14 @@ my ($count, $config, $sleep_interval, $lockfile, $daemon) = (1, 'SYSCONFDIR/open # set upper bound on number of rows in the resultset # before Clark refuses to try to draw a chart my $max_rows_for_charts = 1000; +my $statement_timeout = 10 * 60 * 1000; GetOptions( "daemon" => \$daemon, "sleep=i" => \$sleep_interval, "concurrency=i" => \$count, "max-rows-for-charts=i" => \$max_rows_for_charts, + "statement-timeout=i" => \$statement_timeout, "bootstrap|boostrap=s" => \$config, "lockfile=s" => \$lockfile, ); @@ -208,6 +210,7 @@ for my $r ( @reports ) { RaiseError => 1 } ); + $data_dbh->do('SET statement_timeout = ?', {}, $statement_timeout); try { $state_dbh->do(<<' SQL',{}, $r->{id});