Configuration of periodic tasks executed with a distributed lock. A dictionary where the keys are task names. If hosts are specified in run_on_hosts, the task will switch to any of them at the first opportunity and will keep running there until a new preferred host is specified or a failover occurs due to an error. By adjusting the timing settings, you can override the lock acquisition policy.
# yaml
default: {}
description: |
Configuration of periodic tasks executed with a distributed lock.
A dictionary where the keys are task names.
If hosts are specified in run_on_hosts, the task will switch to
any of them at the first opportunity and will keep running
there until a new preferred host is specified or a failover occurs due to
an error. By adjusting the timing settings,
you can override the lock acquisition policy.
schema:
type: object
additionalProperties:
$ref: '#/definitions/TaskSettings'
definitions:
TaskSettings:
type: object
description: Periodic task policy settings
additionalProperties: false
properties:
run_on_hosts:
description: >
A list of priority hosts. Other hosts will automatically start the task
after the successful liveness checks and shared idle interval described
by `fallback_heartbeat_checks`. An empty list disables the task on all
hosts. If this field is not specified, all hosts have equal priority and
fallback is disabled. A nonempty list enables release-history retention
on every participant, including priority hosts: release updates the lock
row instead of deleting it. Deploy support for this policy to all
participants with fallback disabled before enabling a common nonempty
list. Older versions can delete their own lock row and lose the history
needed by fallback. The `DoWork` method must check `IsCancelAdvised()`
to terminate fallback after `fallback_duration` has elapsed.
type: array
x-usrv-cpp-type: std::unordered_set
items:
type: string
fallback_heartbeat_checks:
description: >
Number of consecutive successful checks that must find no live lock.
Acquisition also requires the lock row to record no activity for at
least this count multiplied by `acquire_interval`. If a sequence of
checks finishes before this shared interval has elapsed, another
sequence is required. With regular successful checks, failover may
therefore take nearly twice this interval; errors and scheduling delays
can extend the wait. Any successful acquisition restarts the shared
waiting period for all fallback hosts.
type: integer
minimum: 1
default: 50
fallback_duration:
description: >
Advisory duration of fallback execution in milliseconds. Once it
expires, `DoWork` must observe `IsCancelAdvised()` and finish its current
iteration, returning priority to the preferred hosts.
type: integer
x-usrv-cpp-type: std::chrono::milliseconds
minimum: 1
default: 600000
acquire_interval:
description: |
How often to try to acquire the lock.
type: integer
x-usrv-cpp-type: std::chrono::milliseconds
prolong_interval:
description: |
How often to attempt to renew
the lock while holding it.
type: integer
x-usrv-cpp-type: std::chrono::milliseconds
lock_ttl:
description: Duration of lock
type: integer
x-usrv-cpp-type: std::chrono::milliseconds
forced_stop_margin:
description: |
How long to allow the component to
finish work when it cannot acquire the lock.
type: integer
x-usrv-cpp-type: std::chrono::milliseconds
worker_func_restart_delay:
description: |
Delay before `DoWork` is restarted after exiting with or without an exception.
type: integer
x-usrv-cpp-type: std::chrono::milliseconds