[{class => 'ahr', field => 'request_time', direction => 'DESC'}]
if $self->{newest_first};
- my $holds = $self->editor->json_query($query, {substream => 1});
+ # KCLS JBAS-1741
+ # Fetch hold IDs in pages so that multiple IDs can be packaged per
+ # message, saving a lot of osrf message boilerplate bulk, without
+ # creating individual messages so large/extensive ejabberd is too
+ # busy to allow other messages through, causing delays / timeouts in
+ # other services.
+ my @ids;
+ $query->{offset} = 0;
+ $query->{limit} = 10000;
+ while (1) {
+ my $holds = $self->editor->json_query($query, {timeout => 600});
+ push(@ids, map {$_->{id}} @$holds);
+
+ # all done if number of holds retrieved is less than the limit.
+ last if @$holds < $query->{limit};
+
+ $query->{offset} += $query->{limit};
+ }
- return map {$_->{id}} @$holds;
+ return @ids;
}
sub editor {