Skip to content

Commit

Permalink
(2.6) dcache-webadmin: put limit on entries in alarms table
Browse files Browse the repository at this point in the history
In order to avoid OOM.

This is hard-coded as effectively the capacity to hold more than 10000 entries in memory should not be required.  One can always adjust the numbers or refine the query in order to retrieve subsets of a larger set.

Testing: Rechecked interactively.

Target: 2.6
Patch: http://rb.dcache.org/r/6344/
Bug: http://rt.dcache.org/Ticket/Display.html?id=8084
Require-book: no
Require-notes: no
Acked-by: Karsten
Committed: 0bd6afa
  • Loading branch information
alrossi committed Dec 12, 2013
1 parent 9f86596 commit 5ea3d0e
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -83,6 +83,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* @author arossi
*/
public class AlarmJDOUtils {
private static final int MAXIMUM_QUERY_RESULTS = 10000;

public static class AlarmDAOFilter {
private String filter;
Expand Down Expand Up @@ -143,17 +144,24 @@ public static Query createQuery(PersistenceManager pm, AlarmDAOFilter filter) {
Integer to;
Query query = pm.newQuery(LogEntry.class);

/*
* 2013/12/11 -- added a range limit guard. This can be hard-coded
* as effectively the capacity to hold more than 10000 entries in
* memory should not be required. One can always adjust the numbers or
* refine the query.
*/
if (filter != null) {
expression = filter.filter;
parameters = filter.parameters;
filter.normalizeRange();
from = filter.rangeStart;
to = filter.rangeEnd;
from = filter.rangeStart == null ? 0
: filter.rangeStart;
int limit = from + MAXIMUM_QUERY_RESULTS;
to = filter.rangeEnd == null ? limit
: Math.min(filter.rangeEnd, limit);
query.setFilter(expression);
query.declareParameters(parameters);
if (from != null) {
query.setRange(from, to);
}
query.setRange(from, to);
} else {
expression = null;
parameters = null;
Expand Down

0 comments on commit 5ea3d0e

Please sign in to comment.