]> git.evergreen-ils.org Git - Evergreen.git/commit
LP#1435494: set limits on Clark Kent's resource usage
authorGalen Charlton <gmc@esilibrary.com>
Fri, 20 Mar 2015 20:33:39 +0000 (20:33 +0000)
committerBen Shum <bshum@biblio.org>
Fri, 10 Apr 2015 02:02:10 +0000 (22:02 -0400)
commit427cb93b5b5d2ce7ae2c9e41bfa54b1c13f3ea0a
tree6f492641092cfc0375234e61044d489b20fe62a0
parent892fcc25dbd1fa3489524c0238456a922f7956a7
LP#1435494: set limits on Clark Kent's resource usage

Clark Kent can sometimes consume more RAM, swap space, or CPU
than is reasonable or productive. For example:

- a badly constructed query with multiple Cartesian joins may
  never terminate, potentially tying up a Clark child process,
  pegging a CPU on the database server, and/or causing significant
  scratch disk usage on the database server keeping a snapshot alive.
- a query that returns a very large number of rows can cause a Clark
  child to bloat, and in extreme cases cause a OOM on the server
  running Clark.
- a report that asks for a chart of an unreasonably large number of
  rows can peg a CPU on the Clark server as GD::Graph attempts to
  compute sub-pixel graph elements.

In each of these cases, a requested report may never finish.

This patch adds the ability set set some limits on Clark.  These
limits can be set either in opensrf.xml for the settings service
to distribute or via command-line switches to clark-kent.pl:

//reporter/setup/statement_timeout / --statement-timeout

  Number of minutes to allow a report's underlying SQL query
  to run before it gets cancelled.  Default value is
  60 minutes.  If a report's query gets cancelled, the
  error_text value will be set to a valid that indicates that
  the allowed time was exceeded.

//reporter/setup/max_rows_for_charts / --max-rows-for-charts

  Number of rows permitted in the query's output before
  Clark Kent refuses to attempt to draw a graph. Default
  value is 1,000 rows.

//reporter/setup/resultset_limit / --resultset-limit

  If set, truncates the report's output to the specified
  number of hits.  Note that it will not be apparent
  to a staff user if the report's output has been
  truncated.  Default value is unlimited.

This patch also adds the ability for the concurrency
to be set via an opensrf.xml setting (//reporter/setup/parallel).

If both a command-line switch and an opensrf.xml setting
are supplied, the value set in the command line takes
precedence.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/examples/opensrf.xml.example
Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm
Open-ILS/src/reporter/clark-kent.pl