Clustering#
Querona can run as a two-node failover cluster. Two Querona installations share one metabase, and one of them serves clients at a time. The other one takes over the serving role in a planned failover, at once, or after a failure, once an operator has authorized it (in the manual failover mode), and clients reconnect to it under the same name. The model is that of a SQL Server failover cluster instance: there is one shared copy of everything the instance knows, and the whole instance moves from one server to the other.
This section describes the cluster: what it is, what it needs, how clients connect to it, how to set it up and how to run it.
Terms#
Term |
Meaning |
|---|---|
Node |
One Querona installation that is a member of the cluster, on a Windows server of its own. A cluster has exactly two nodes. |
Serving node |
The node that serves clients. It is the only node that opens the client ports - the TDS port and the web port of the Administrative Portal and the API - and the only one that runs jobs, Data API instances and Spark instances. |
Standby node |
The other node. It keeps the metadata loaded from the metabase and is ready to take over, but it accepts no client connection. It answers only the health probes on its administrative port. |
Lease |
A record in the metabase that names the serving node. The serving node renews it every 5 seconds. When it stops renewing, the lease expires after its time to live (30 seconds by default) from the last renewal, and only then can the other node take it. |
Failover |
The move of the serving role from one node to the other. A planned failover moves it while both nodes run; a takeover moves it after the serving node has failed. |
Failover mode |
Whether the standby node takes over by itself (automatic) or only when an operator authorizes it (manual). |
Cluster name |
The DNS name clients connect to, the same whichever node serves. |
How it works#
flowchart LR
C["Clients<br/>cluster name"] --> S["Serving node<br/>client ports open"]
C -.-> B["Standby node<br/>client ports closed"]
S -- "renews the lease,<br/>reads and writes" --> M[("Metabase<br/>SQL Server with<br/>high availability")]
B -- "reads the metadata,<br/>waits for the lease" --> M
Both nodes connect to the same metabase. The metabase holds everything the instance knows - the virtual databases, connections, logins and permissions, jobs and schedules - and the lease. It is the only thing the nodes share and the only way they coordinate: they do not connect to each other.
The serving node holds the lease and renews it. Every change it writes to the metabase is checked against the lease, so a node that has lost the lease cannot change the metabase any more, even if it does not know yet that it lost it.
The standby node loads the metadata from the metabase and loads it again whenever the serving node changes it, so a takeover starts from current metadata.
When the serving node loses its connection to the metabase, it stops serving on its own within 20 seconds (by default) of its last successful renewal. When its server fails, it stops serving with it. Either way the lease expires after its time to live (30 seconds by default) from the last renewal, and the standby node can then take the lease - in the manual failover mode once an operator has authorized it - load the metadata, start the jobs, Data API instances and Spark instances, and open the client ports.
The serving node checks before every TDS request and every web request that it still holds the lease with time left
to act on it. When it stops acting, it closes its client ports and breaks its open sessions at once: each client’s
connection is closed and the statements the sessions run are cancelled. A TDS client sees its connection break with
the outcome of its request unknown; a web request that arrives afterwards is answered 503 and runs nothing. A node
whose process or virtual machine was suspended past its lease therefore serves no request when it resumes. A virtual
machine that is paused or saved stops the node’s internal timer with it, so the node also compares its wall clock,
which the host corrects at the resume: when the wall clock shows that the lease time has passed, the node refuses
every request until it has confirmed the lease with the metabase, and leaves the role when it cannot. A planned
failover and a clean stop do not break sessions this way: they let running statements finish first, and a planned
failover also lets open transactions finish, while it closes idle connections and refuses new requests.
Note
A request admitted just before the node stopped acting can still start a statement against a data source while the node breaks its sessions, and a statement a data source has already received may complete there even though the node cancels it. Such effects are not protected by the lease (see What a failover can leave unknown). A process that hangs entirely keeps its client ports at the network level until it is stopped (see Client connections to a cluster).
Compared with a SQL Server failover cluster instance:
Concern |
SQL Server failover cluster instance |
Querona cluster |
|---|---|---|
What is shared |
The instance’s databases on shared storage |
The metabase, a SQL Server database with high availability of its own |
What decides which node serves |
Windows Server Failover Clustering |
The lease in the metabase; no Windows Server Failover Clustering is needed for the Querona nodes |
What clients connect to |
The virtual network name |
The cluster name in DNS (see Client connections to a cluster) |
|
The virtual server name, on both nodes |
The first label of the cluster name, on both nodes (see Cluster) |
What moves at a failover |
The whole instance: databases, logins, jobs |
The whole instance: the client ports, jobs, Data API instances and Spark instances |
Data stays in the data sources: the cluster protects the Querona service, not the sources it reads.
Failover modes#
The failover mode belongs to the cluster, is stored with the lease, and is changed with qua_cluster_set_failover_mode. A newly provisioned cluster is in manual mode.
Manual (the supported mode). The standby node takes over only when an operator authorizes it, after checking that the serving node is really down, on the standby node’s node management page. A planned failover with qua_cluster_failover moves the role in either mode.
Automatic. The standby node takes over by itself once the lease has expired, at most once in 6 hours, and takes the lease the serving node released when it stopped cleanly without counting it towards that limit.
Warning
Automatic failover mode is not supported. Run production clusters in manual failover mode.
Pilot clusters#
A cluster node does not start while credentials stored in the metabase are still encrypted under the shared secret of
its instance configuration file rather than under the instance master key. The setting ClusterPilotMode lets a node
start anyway, so that a cluster can be tried out while the cause is being fixed.
Warning
A pilot cluster is not fit for production. Each pilot node logs a warning at every start, and the Cluster page warns while either node runs as a pilot. See Protect stored credentials for the setting and the way out of it.
Limits#
A cluster has exactly two nodes. Several Querona instances on one metabase without cluster mode are not supported.
The metabase must be on SQL Server, with synchronous high availability. It is the single point of failure of the cluster: without it, the serving node stops serving after 20 seconds even when both nodes are healthy (see Cluster requirements).
The standby node serves no clients: no queries, no Administrative Portal and no API.
A failover ends every client session and every portal sign-in. Clients reconnect; nothing is resumed for them.
A statement already sent to a data source when the node stops acting may complete there (see the note under How it works).
A planned failover takes up to 10 seconds for running statements and open transactions to finish plus a full load of the metadata on the node that takes over. A takeover after a failure takes until the lease has expired, plus up to one acquisition interval (5 seconds by default), plus that metadata load - and, in the manual failover mode, the time until an operator authorizes it.
During a planned failover a statement federated to Spark that reads data of Querona back through the Spark driver fails, and a transaction open in the Admin Portal’s query editor is rolled back (see Cluster operations and recovery).
Effects outside the metabase - statements sent to data sources, files written by job steps - are not protected by the lease (see What a failover can leave unknown).
There is no rolling upgrade: both nodes are upgraded in one outage (see Cluster operations and recovery).
A connection pinned to one instance, a network of instances other than the two cluster nodes, and the query hint
OPTION (EXECUTE_ON ...)are refused in cluster mode.Data API instances and Spark instances run only on the serving node and start anew at every takeover; what they held in memory is lost.
In this section#
Page |
What it covers |
|---|---|
The metabase, the nodes, the service account, ports, certificates and service principal names. |
|
The cluster name in DNS, client settings, what a client sees during a failover. |
|
Installing both nodes, preflight, provisioning, switching cluster mode on. |
|
Planned failover, takeover, restarts, a faulted node, restoring the metabase, upgrades. |
|
Jobs and other work whose outcome a failover can leave unknown. |
Reference:
Cluster - the Cluster page of the serving node, and what clients and tools see.
Node management page - the node management page and the takeover authorization.
Health endpoints - the health probes.
The cluster procedures: qua_cluster_preflight, qua_cluster_provision, qua_cluster_failover, qua_cluster_set_failover_mode, qua_cluster_set_name and qua_cluster_set_timings.