qua_cluster_set_timings#
Changes the lease timings of a two-node cluster, which its metabase stores, and returns one row per timing. Each node uses the changed timings from its next start.
Syntax#
qua_cluster_set_timings
[ [ @ttl_milliseconds = ] ttl_milliseconds ]
[ , [ @renew_interval_milliseconds = ] renew_interval_milliseconds ]
[ , [ @acquire_interval_milliseconds = ] acquire_interval_milliseconds ]
[ , [ @self_demote_milliseconds = ] self_demote_milliseconds ]
[ , [ @lock_timeout_milliseconds = ] lock_timeout_milliseconds ]
[ , [ @statement_timeout_milliseconds = ] statement_timeout_milliseconds ]
[ , [ @connect_timeout_milliseconds = ] connect_timeout_milliseconds ]
[ , [ @unbind_budget_milliseconds = ] unbind_budget_milliseconds ]
[ , [ @clock_step_allowance_milliseconds = ] clock_step_allowance_milliseconds ]
[ , [ @handoff_ttl_milliseconds = ] handoff_ttl_milliseconds ]
[ , [ @hold_down_milliseconds = ] hold_down_milliseconds ]
[ , [ @anti_flap_period_minutes = ] anti_flap_period_minutes ]
[ , [ @waiting_for_lease_alert_minutes = ] waiting_for_lease_alert_minutes ]
[ , [ @dry_run = ] dry_run ] [;]
Arguments#
Every timing argument is optional and of type int. A timing left out, or given as NULL, keeps the value the
metabase stores.
Argument |
Recommended |
Meaning |
|---|---|---|
|
30000 |
How long the lease stays valid after the serving node last renewed it; after that the other node may take it. |
|
5000 |
How often the serving node renews the lease. |
|
5000 |
How often a node that is allowed to take the lease tries to. |
|
20000 |
How long after the start of its last successful renewal the serving node stops serving on its own. |
|
3000 |
How long a lease statement waits for a lock. |
|
4000 |
How long a lease statement may run. |
|
4000 |
How long opening a connection to the metabase may take. |
|
2000 |
How long a node that stops serving may take to close its client ports. |
|
5000 |
How far the clock of the metabase server may step. |
|
30000 |
How long after a planned handoff begins only its target may take the lease. |
|
30000 |
How long a node that lost the lease waits before it tries to take it back. |
|
360 |
The period in which a failed node is taken over automatically at most once. |
|
5 |
How long a standby waits for the lease, while no live node holds it, before it logs a warning. |
A new cluster gets the recommended values when it is provisioned. A timing may be at most ten times its recommended value.
[ @dry_run = ] dry_run
1 reports what the procedure would do and changes nothing. Optional; the default is 0.
Result set#
One row per timing, in the order of the arguments.
Column |
Type |
Description |
|---|---|---|
cluster_id |
uniqueidentifier |
The identifier of the cluster. |
timing_name |
nvarchar(64) |
The name of the argument that sets the timing, without |
stored_value |
int |
The value the metabase stored before the call. |
new_value |
int |
The value the metabase stores after the call, or would store in a dry run. |
recommended_value |
int |
The recommended value. |
is_changed |
bit |
1 when the new value differs from the stored one. |
is_below_recommended |
bit |
1 when the new value is below the recommended one. |
is_dry_run |
bit |
1 when nothing was changed because |
After a change the procedure also sends the message that each node uses the timings from its next start, and writes a
Cluster: line with the old and new values into the log of the instance it runs on.
Remarks#
The timings are checked together with the ones the call leaves as they are, the way an instance checks them when it starts in cluster mode, and the call is refused when a timing is not positive or the timings break this chain:
the lock timeout is shorter than the statement timeout, and the statement timeout shorter than the renewal interval;
three renewal intervals fit into the self-demote period;
the self-demote period, the unbind budget and the clock-step allowance together are shorter than the time to live.
The call is also refused when a timing is more than ten times its recommended value, and when the serving instance could not shut down within the 30 seconds Querona gives a cluster node: the unbind budget, 15 seconds for the running jobs to end, 3 seconds for the external processes, and the connect timeout, the statement timeout and one more second for the release of the lease must add up to at most 30 seconds. With the recommended values they add up to 29 seconds, which leaves one second for a longer unbind budget or connect timeout; the statement timeout is bounded by the renewal interval first. A shutdown that begins while a planned failover the instance started is still open also cancels that failover, which can take longer than the 30 seconds.
The error names each rule that does not hold: a timing that is not positive by its name, a broken link of the chain
(for example LockTimeoutBelowStatementTimeout), a timing above its maximum as <timing>AtMostTenTimesRecommended,
and the shutdown as ShutdownWithinLimit.
A refused call changes nothing. A timing below its recommended value is allowed and marked in its row; each instance logs a warning about it when it starts. An instance that starts with stored timings that break the chain refuses to start; one whose stored timings break only the maximum or the shutdown limit starts and logs a warning, so that its timings can still be changed. Every call checks all the timings, so such a call must bring every timing back within the limits at once, a dry run included; the error names the rules that still do not hold.
With the defaults the serving node rides out a metabase outage of about 15 seconds in the worst case, minus the lease call in flight - an estimate from the lease’s timing model. A metabase that fails over more slowly, for example a mirrored metabase whose principal hangs, makes the serving node step down; lengthen the chain for it, for example to a self-demote period of 35 seconds and a time to live of 45 seconds. A crashed node then takes 15 seconds longer to be replaced.
Run the procedure on the instance that serves the cluster; an instance in cluster mode that does not serve refuses a change but not a dry run, which only reads. The standby has no client port, so in practice both run on the serving instance. Before the first instance is restarted in cluster mode, the procedure also runs there, outside cluster mode. It is refused when the metabase carries no cluster or more than one.
Each instance reads the timings when it starts, so restart the instances one after the other for the change to take
effect. Until both have restarted they run different timings, which is safe. The change is stored when the procedure
ends, outside any transaction the session has open, so a ROLLBACK does not undo it. Do not run the procedure while
qua_cluster_provision runs or while the cluster is reset.
Permissions#
Requires the CONTROL SERVER permission.
Example#
Shows the effect of a longer chain for a metabase that fails over slowly, then stores it.
EXEC qua_cluster_set_timings @self_demote_milliseconds = 35000, @ttl_milliseconds = 45000, @dry_run = 1;
EXEC qua_cluster_set_timings @self_demote_milliseconds = 35000, @ttl_milliseconds = 45000;