Skip to content

Commit e572a71

Browse files
ryanjdewMarkLogic Builder
authored andcommitted
DHFPROD-8258: Reduce index sleep escalation and look for SVC-EXTIME
1 parent 2aba7d6 commit e572a71

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.smart-mastering/impl/util.xqy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,13 @@ declare function util-impl:process-items-in-set-time(
283283
for $item in $items
284284
return $fun($item)
285285
} catch ($e) {
286-
if ($e/error:code eq "XDMP-EXTIME") then (
286+
if ($e/error:code = ("XDMP-EXTIME", "SVC-EXTIME")) then (
287287
let $items-cost := $items ! $item-cost-fun(.)
288288
let $high-outliers-cost := util-impl:determine-high-outliers($items-cost)
289289
let $high-outlier-indexes := $high-outliers-cost ! fn:index-of($items-cost, .)
290-
let $high-outliers := $items[fn:position() = $high-outlier-indexes]
291-
let $others := $items[fn:not(fn:position() = $high-outlier-indexes)]
290+
let $others := if (fn:count($high-outlier-indexes) eq 0) then () else $items[fn:not(fn:position() = $high-outlier-indexes)]
291+
(: If there are no high outliers, than all items have a high cost and should be handled by our high outlier function :)
292+
let $high-outliers := if (fn:empty($others)) then $items else $items[fn:position() = $high-outlier-indexes]
292293
return (
293294
util-impl:process-items-in-set-time(
294295
$fun,

marklogic-data-hub/src/test/ml-modules/root/test/data-hub-test-helper.xqy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,20 +374,20 @@ declare function run-with-roles-and-privileges($roles, $privileges, $func-or-mod
374374
declare function wait-for-indexes()
375375
{
376376
try {
377-
wait-for-indexes(1)
377+
run-with-roles-and-privileges("admin", (), function() {
378+
wait-for-indexes(1)
379+
}, ())
378380
} catch ($e) {
379-
if ($e/error:code = "XDMP-EXTIME") then ()
381+
if ($e/error:code = ("XDMP-EXTIME", "SVC-EXTIME")) then ()
380382
else xdmp:rethrow()
381383
}
382384
};
383385

384386
declare function wait-for-indexes($count as xs:unsignedLong) {
385-
let $is-indexing := run-with-roles-and-privileges("admin", (), function() {
386-
0 lt fn:sum(xdmp:forest-counts(xdmp:database-forests(xdmp:database()), (), "preview-reindexer")/*:reindex-refragment-fragment-count, 0)
387-
}, ())
387+
let $is-indexing := 0 lt fn:sum(xdmp:forest-counts(xdmp:database-forests(xdmp:database()), (), "preview-reindexer")/*:reindex-refragment-fragment-count, 0)
388388
return
389-
if ($is-indexing) then
390-
let $_sleep := xdmp:sleep(5 * $count)
389+
if ($is-indexing and $count lt 250) then
390+
let $_sleep := xdmp:sleep(250 * (($count idiv 100) + 1))
391391
return wait-for-indexes($count + 1)
392392
else
393393
()

0 commit comments

Comments
 (0)