SWITCH COLD STORAGE ROLE
Moves the cold storage manager role between instances at runtime, and reports the role an instance currently holds. Exactly one instance in a cluster owns uploads, manifest writes, and remote garbage collection; these statements move that ownership without restarting either instance, which is how a manager is replaced during maintenance or after a failure.
Cold storage is available in QuestDB Enterprise only.
Syntax
SWITCH COLD STORAGE ROLE TO { MANAGER | REFRESHER }
[FORCE]
[TIMEOUT milliseconds];
SWITCH COLD STORAGE STATUS;
Description
Both statements act on the instance that executes them, not on the cluster. Issue them against the specific node whose role you want to change or inspect.
| Clause | Effect |
|---|---|
TO MANAGER | Claims the manager lock and opens manager work on this instance |
TO REFRESHER | Flushes pending manifest state, releases the lock, and drops to read-only mirroring |
FORCE | Deletes an existing foreign lock before claiming it |
TIMEOUT | Bounds how long the calling session waits, in milliseconds |
The role is independent of the replication primary and replica roles. Promoting a replica to primary does not move the manager role, and moving the manager role does not affect replication.
A role set this way does not survive a restart. Update cold.storage.role in server.conf after a durable handoff, otherwise the instance boots back into its configured role.
Status columns
SWITCH COLD STORAGE STATUS returns a single row with two columns:
| Column | Type | Description |
|---|---|---|
state | STRING | REFRESHER, PROMOTING, MANAGER, or DEMOTING |
term | LONG | Ownership term, positive only while manager work is being accepted |
PROMOTING and DEMOTING are transient. A stable role is REFRESHER or MANAGER; treat a MANAGER state with a non-positive term as not yet accepting work.
Timeout behaviour
TIMEOUT bounds only the calling session. The transition itself continues to a stable state regardless, and a timeout never rolls it back. If a statement times out, poll SWITCH COLD STORAGE STATUS to see where the transition settled rather than reissuing the switch.
Permissions
Both statements require database administrator (system admin) privileges, including with FORCE. They are not grantable through RBAC permissions.
Examples
The supported handoff is two steps, on two different instances, in this order:
SWITCH COLD STORAGE ROLE TO REFRESHER;
SWITCH COLD STORAGE STATUS;
| state | term |
|---|---|
| REFRESHER | 0 |
SWITCH COLD STORAGE ROLE TO MANAGER;
SWITCH COLD STORAGE STATUS;
| state | term |
|---|---|
| MANAGER | 4 |
Bound the caller's wait to 30 seconds:
SWITCH COLD STORAGE ROLE TO REFRESHER TIMEOUT 30000;
Take over when the previous manager cannot demote itself:
SWITCH COLD STORAGE ROLE TO MANAGER FORCE;
FORCE deletes the existing manager lock and claims ownership. It is a recovery path, not a fencing protocol: stop the previous manager, or prove it is dead, before issuing it. Two active managers write byte-divergent Parquet for the same partition and corrupt cold reads.
See also
- Cold storage for roles and the object store layout
- Operating cold storage for the full handoff procedure and its preconditions
cold.storage.rolefor the boot role- Replication overview for the primary and replica roles this one is independent of