Cluster operations and recovery#
This page describes the everyday operations of a cluster in manual failover mode and what to do when something fails.
Every cluster operation is recorded in the node’s log, querona-<date>.log under C:\ProgramData\Querona\logs,
in lines that start with Cluster:; each node also writes a status line every 5 minutes. The state of both nodes is
on the Cluster page of the serving node, and the state of one node on its own
node management page.
Planned failover#
To move the serving role while both nodes run - before maintenance of the serving node’s server, for example - run on the serving node:
EXEC qua_cluster_failover;
The procedure checks that the standby node is ready, then the serving node stops accepting connections and begins no new request: it closes the connections that wait for their next request, refuses a new request on the others, and gives running statements and open transactions up to 10 seconds to finish. It then ends every session, stops its jobs - a job step that was about to start does not start - and hands the lease to the standby node, which loads the metadata and opens its client ports. A planned failover works in either failover mode. See qua_cluster_failover.
Jobs that were running are stopped as at a clean shutdown and recorded as canceled; a job that does not stop within 15 seconds is recorded as failed, with an unknown outcome. See What a failover can leave unknown.
Two kinds of work do not survive a planned failover, so run it when none of them runs:
A statement federated to Spark that reads data of Querona back through the Spark driver fails if it needs that read while the serving node hands the role over: the driver reads over a new connection to the client port, which no longer accepts.
A transaction open in the query editor of the Admin Portal is rolled back: the portal’s requests are refused while the node hands the role over, the commit included.
Stopping and restarting nodes#
The standby node can be stopped and restarted at any time; clients do not notice.
A clean stop of the serving node fails over only in automatic mode. The node releases the lease. In manual mode the standby node does not take it by itself: the cluster serves no clients until the stopped node starts again and takes the role back, or until an operator authorizes a takeover on the standby node. To keep serving, run a planned failover first. In automatic mode the standby node takes the released lease at its next attempt, within a few seconds; this takeover does not start the anti-flapping period (see A faulted node below), but while a period started by an earlier failure still runs, the standby node waits as in manual mode.
A restart of the serving node’s server acts as a crash. When Windows shuts down, it gives the Querona service less time than the cluster needs for an orderly stop, so the node does not release the lease. In manual mode the other node does not take over; the node takes the role back after the restart, and its running jobs end as after a crash. Before you install updates that restart the server, run a planned failover, or stop the service.
To restart both nodes, for example after a change of the lease timings, restart the standby node, run a planned failover to it, and then restart the other node.
Takeover after a failure#
In manual mode, when the serving node fails, the standby node waits for an operator. Its log reports that it is waiting for the lease and why, and after 5 minutes of waiting it logs a warning.
Check that the serving node is really down: its server does not answer, or its Querona service has stopped. A takeover cannot take the role from a node that still renews its lease; to move the role from a running node, use a planned failover.
If the serving node’s process hangs - its service does not respond, but it still holds the TDS port - stop the service or end the process on that node. Clients keep reaching a hung node (see Client connections to a cluster).
Sign in to the standby node’s server, for example over Remote Desktop, open the node management page at
http://localhost:8080/(the node’s administrative port), and authorize the takeover. A runbook can do the same with the takeover script on that server, run there directly or from another computer over PowerShell remoting. The node takes the lease at its next acquisition attempt after the failed node’s lease has expired: about 30 to 35 seconds after the last renewal with the default timings. See Taking the serving role over.
The takeover requires the CONTROL SERVER permission. A standby node that cannot use the instance master key does
not take over by itself; authorizing a takeover on it makes it serve without any stored credential (see
Protect stored credentials).
When the failed node is repaired and started again, it joins as the standby node.
Note
A takeover can fail with lock timeouts when the metabase server stalls in the middle of the failed node’s last commit: the metabase keeps that session’s lock until the session ends. Stop the failed node, or end its session on the metabase server.
When the metabase is unreachable#
A running node stays up. The serving node stops serving within 20 seconds (by default) of its last successful lease renewal: it closes its client ports, breaks its open sessions and stops its jobs, Data API instances and Spark instances, but its process keeps running. When the metabase is back, the node takes the role again.
A node that starts while the metabase is unreachable does not start. It logs an error and exits after about 23 seconds, before it opens its administrative port, so its health probes do not answer. Windows starts the service again 14 seconds later and keeps retrying, so the node starts by itself once the metabase is back.
A metabase failover that takes longer than the serving node rides out stops it serving; see Cluster requirements for the lease timings.
A faulted node#
A node that loses the serving role three times within 10 minutes - for example because its network or the metabase
fails again and again - stops trying to take the role and enters the state Faulted. The Cluster page and the node’s
health report its role as RESOLVING and its operational state as FAILED. The node’s log, and
Last transition reason on its node management page, say why.
In the automatic failover mode there is a second limit: after an automatic takeover, the next automatic takeover waits for the end of the anti-flapping period, 6 hours by default, and until then a takeover needs an operator’s authorization. Taking a lease that the serving node released when its Querona service stopped cleanly does not start the period, so stopping and starting that service - to install a Querona update, for example - leaves the next failure to be taken over automatically. Any stop of the service counts, whoever requests it - an operator, a script or a monitoring tool.
Either case can leave the cluster without a serving node until an operator acts. Windows Server Failover Clustering behaves the same way when a role fails more often than its failover threshold allows: it leaves the role failed.
A node leaves Faulted only when its Querona service restarts. Fix the cause, then restart the Querona service on that node, over Remote Desktop or PowerShell remoting. If the other node waits as the standby node meanwhile, you can authorize a takeover there instead.
When a node’s log reports that the lease rows of the cluster contradict each other or are missing, the node stops taking the lease. Stop both nodes and reset the cluster, as for a restored metabase below.
Restoring the metabase#
A restore rolls the lease back to the time of the backup. Before the nodes may run on a restored metabase, the cluster is reset: the reset gives it a new cluster identifier, so that nothing from before the restore - an old lease, an open planned failover, a node that still acts on an old lease - is accepted any more.
Stop the Querona service on both nodes, and wait the lease time to live plus the clock-step allowance - 35 seconds with the default timings - so that the lease has expired and no node counts as active any more.
Restore the metabase, and its high availability.
On the metabase database, for example in SQL Server Management Studio, run:
EXEC dbo.ClusterReset;
The reset keeps the cluster name, the lease timings and the failover mode, and ends an anti-flapping period in progress: in automatic mode, the next failure after the reset is taken over automatically. It is refused while the lease has not expired (error 50103), while a node reached the metabase within the lease’s time to live (50104), and while a session of a cluster node is connected to the metabase (50105); stop both nodes, wait, and run it again. Seeing the other sessions needs
VIEW SERVER PERFORMANCE STATE(VIEW SERVER STATEbefore SQL Server 2022); without it the session check is skipped.If the restored metabase has another server or database name, change
MetadataConnectionStringin theinstance.configof both nodes.Start both nodes. The first that takes the lease serves.
Job executions that were unfinished in the backup are closed at the first start as failed, with an unknown outcome. A backup taken before the stored credentials were moved under the instance master key holds them under the shared secret again; see Protect stored credentials.
After a takeover: what starts empty#
The node that takes over starts its processes anew:
Spark instances start on the new serving node; a driver the other node ran is never reused. Data held in Spark’s memory - the in-memory modes of materialization - is empty and is loaded again on first use or at the next refresh. Materialized data on disk stays, because the warehouse is on shared storage (see Cluster requirements).
Data API instances marked to start automatically start on the new serving node (see Managing Data API).
The Engine’s own in-memory state - the plan cache and other data held in the process - starts empty on the new serving node.
See Instance configuration for how Spark instances follow the serving role.
Rebuilding a node#
To replace a node’s server, give the new server the host name of the node it replaces: each node is bound to its host name and does not start on another computer. Then:
Install Querona on it as a Cluster node, against the cluster’s metabase, while the other node serves. Follow Install a node again over an existing metabase.
Set
InstanceId,InstanceName,ClusterModeEnabled,AdministrativeHttpPortandMetabaseEngineTypein itsinstance.configto the values of the node it replaces (see Set up a cluster). The Cluster page names each node by its instance name and host; the tooltip of the name shows the id.Give it the instance master key with the passphrase file and start it, as in Join the second node of a cluster.
Warning
A new installation over an existing metabase has no earlier instance configuration to compare with. When its
metabase login differs from the one stored for the Hive metastore, or the stored Hive metastore password is not yet
under the instance master key, the installation writes that password encrypted with the shared secret the installer
ships, and its log says The Hive metastore password is written under this node's shared secret. The node then
starts with the shipped shared secret and without the master key until the passphrase file gives it the key. Follow
Install a node again over an existing metabase to the end, and check that the node’s log carries no error about
credentials left under the shared secret.
The installation in the first step shows and stores the ports, the web certificate and the HTTPS setting of the
instance bound to the server’s computer name, which is the instance of the node it replaces, and leaves the other
node’s settings alone - also when the server keeps an instance.config from an earlier installation, or the
installation runs again before the second step, while InstanceId still names the other node’s instance. A rebuilt
node with a new certificate therefore gets it by choosing it in the instance parameters dialog. The installation log
names the instance in a line starting with The instance parameters of instance.
Upgrading#
A cluster is upgraded in one outage; there is no rolling upgrade.
Stop the Querona service on both nodes first, then back up the metabase and the configuration folder of both nodes, so that neither node changes the metabase after the backup. Run the installation on one node, then on the other. The first installation migrates the metabase; the second finds it migrated.
Each installation shows and stores the ports, the web certificate and the HTTPS setting of its own node only: the instance its
instance.confignames, or, when that instance is bound to the other node’s computer, the instance bound to this one. A cluster upgraded with the installer of an earlier release can hold the second node’s certificate as the first node’s; Repair the first node’s settings after an earlier upgrade restores it.Keep
SharedSecretin each node’sinstance.config. A cluster node does not use it, but the installer reads it at an upgrade that reaches the metabase with SQL authentication and finds the Spark connection it configures, and such an upgrade over aninstance.configwithout it fails.Each installation starts the service on its own node when it ends. Only when an installation log says that the Hive metastore password was written again, and a service did not start, start first the node whose installation ran last, and the other node once the first one’s log carries no error about credentials left under the shared secret.
To roll back: stop the Querona service on both nodes, restore the metabase backup and the configuration folders of both nodes, reset the cluster as in Restoring the metabase when the restored metabase holds one, and then remove the new release and install the earlier one on both nodes.
The full procedure is in Upgrade the nodes of a cluster.
Renaming the cluster#
qua_cluster_set_name changes the
cluster name on the serving node. Each node reports the new name from its next start. Before the restarts, create the
new name in DNS, add it to both certificates’ subject alternative names and register its service principal name; then
restart the standby node, run a planned failover to it, and restart the other node. @@SERVERNAME reports the new
name on each node from its restart.
Changing the lease timings#
qua_cluster_set_timings changes the lease timings on the serving node. Each node uses them from its next start; restart the nodes as described in Stopping and restarting nodes.