|
71 | 71 |
|
72 | 72 | local function suspend_basic(scan_space, task, len)
|
73 | 73 | local delay = (task.tuples_per_iteration * task.full_scan_time)
|
74 |
| - delay = math.min(delay / len, constants.max_delay) |
| 74 | + delay = math.min(delay / len, task.iteration_delay) |
75 | 75 | fiber.sleep(delay)
|
76 | 76 | end
|
77 | 77 |
|
@@ -163,8 +163,8 @@ local function worker_loop(task)
|
163 | 163 | task.do_worker_iteration(task)
|
164 | 164 | end
|
165 | 165 |
|
166 |
| - -- iteration is complete, yield |
167 |
| - fiber.sleep(constants.max_delay) |
| 166 | + -- Full scan iteration is complete, yield |
| 167 | + fiber.sleep(task.full_scan_delay) |
168 | 168 | end
|
169 | 169 | end
|
170 | 170 |
|
@@ -247,6 +247,8 @@ local function create_task(name)
|
247 | 247 | is_tuple_expired = nil,
|
248 | 248 | process_expired_tuple = nil,
|
249 | 249 | args = nil,
|
| 250 | + iteration_delay = constants.max_delay, |
| 251 | + full_scan_delay = constants.max_delay, |
250 | 252 | tuples_per_iteration = constants.default_tuples_per_iteration,
|
251 | 253 | full_scan_time = constants.default_full_scan_time,
|
252 | 254 | vinyl_assumed_space_len = constants.default_vinyl_assumed_space_len,
|
|
293 | 295 | -- process_expired_tuple() as additional context
|
294 | 296 | -- * tuples_per_iteration -- number of tuples will be checked by one iteration
|
295 | 297 | -- * full_scan_time -- time required for full index scan (in seconds)
|
| 298 | +-- * iteration_delay -- max sleep time between iterations (in seconds) |
| 299 | +-- * full_scan_delay -- sleep time between full scans (in seconds) |
296 | 300 | -- * force -- run task even on replica
|
297 | 301 | -- }
|
298 | 302 | local function expirationd_run_task(name, space_id, is_tuple_expired, options)
|
@@ -380,6 +384,20 @@ local function expirationd_run_task(name, space_id, is_tuple_expired, options)
|
380 | 384 | task.do_worker_iteration = default_do_worker_iteration
|
381 | 385 | end
|
382 | 386 |
|
| 387 | + if options.iteration_delay ~= nil then |
| 388 | + if type(options.iteration_delay) ~= 'number' then |
| 389 | + error("invalid type of iteration_delay value") |
| 390 | + end |
| 391 | + task.iteration_delay = options.iteration_delay |
| 392 | + end |
| 393 | + |
| 394 | + if options.full_scan_delay ~= nil then |
| 395 | + if type(options.full_scan_delay) ~= 'number' then |
| 396 | + error("invalid type of full_scan_delay value") |
| 397 | + end |
| 398 | + task.full_scan_delay = options.full_scan_delay |
| 399 | + end |
| 400 | + |
383 | 401 | -- put the task to table
|
384 | 402 | task_list[name] = task
|
385 | 403 | -- run
|
|
0 commit comments