-
Notifications
You must be signed in to change notification settings - Fork 102
[docs] Add CRDB survivability configuration #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mickmis
wants to merge
1
commit into
interuss:master
Choose a base branch
from
Orbitalize:survivability-doc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # CockroachDB Pool Survivability | ||
|
|
||
| This document describes how to meet the survivability and high-availability objectives of a DSS pool running on CockroachDB (as described in the [Survivability section of the Architecture Overview](../architecture/index.md#Survivability)). | ||
|
|
||
| For example, in a standard 3-USS pool running 2 CockroachDB nodes per USS (6 nodes total): | ||
| * If we do not restrict where data replicas are placed, CockroachDB might place two of the three replicas of a range on nodes belonging to a single USS. | ||
| * If that USS suffers an outage or goes down for maintenance, we would lose two replicas at once. This breaks the Raft quorum (since only 1 of 3 replicas remains active), causing that range to become unavailable. | ||
| * To prevent this and meet survivability objectives, we must configure the CockroachDB pool to place at least one replica per USS. This guarantees that even if a full USS goes down, 2 out of 3 replicas remain active on the other USSs, maintaining quorum and ensuring uninterrupted DSS operations. | ||
|
|
||
| To achieve this, we: | ||
| 1. Start each CockroachDB node with a specific locality embedding its USS and node identifier. | ||
| 2. Configure replication zones using the CockroachDB `ALTER RANGE` SQL command to enforce placement constraints across the pool. | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Setting Node Locality | ||
|
|
||
| When starting each CockroachDB node, you must configure its `--locality` flag to specify which USS and node it represents. The locality must use first at least the `uss` key, and optionally second the `node` key. | ||
|
|
||
| !!! danger "Ordering Constraint" | ||
| The ordering of the `--locality` flag keys must be exactly the same across all CockroachDB nodes in the cluster (e.g., `uss` first, then `node`). Mixing the order (e.g., `node` then `uss` on some nodes) will cause CockroachDB to treat them as incompatible locality hierarchies and fail to apply constraints correctly. | ||
|
|
||
| ### Flag Format | ||
|
|
||
| ```shell | ||
| --locality=uss=<uss_id>,node=<node_id> | ||
| # or | ||
| --locality=uss=<uss_id> | ||
| ``` | ||
|
|
||
| Where: | ||
| * `<uss_id>` is a unique identifier for the USS organization (e.g., `uss1`, `uss2`, `uss3`). | ||
| * `<node_id>` is a unique identifier for the node within that USS (e.g., `node-0`, `node-1`). | ||
|
|
||
| ### Example Configuration for a 3-USS Pool | ||
|
|
||
| * **USS 1 (uss1)**: | ||
| * Node 0: `--locality=uss=uss1,node=node-0` | ||
| * Node 1: `--locality=uss=uss1,node=node-1` | ||
| * **USS 2 (uss2)**: | ||
| * Node 0: `--locality=uss=uss2,node=node-0` | ||
| * Node 1: `--locality=uss=uss2,node=node-1` | ||
| * **USS 3 (uss3)**: | ||
| * Node 0: `--locality=uss=uss3,node=node-0` | ||
| * Node 1: `--locality=uss=uss3,node=node-1` | ||
|
|
||
|
|
||
| ## 2. Configuring Replication Constraints (`ALTER RANGE`) | ||
|
|
||
| By default, CockroachDB automatically distributes replicas to optimize resource usage and load. To enforce the "one replica per USS" survivability rule, you must manually define replication zone constraints using the `ALTER RANGE default CONFIGURE ZONE` SQL command. | ||
|
|
||
| The `default` range is the cluster-wide catch-all. Any database or table created within the DSS (including the RID and SCD tables) that does not have its own specific zone configuration will inherit these default placement constraints. | ||
|
|
||
| ### The `ALTER RANGE` SQL Statement | ||
|
|
||
| To configure a 3-replica cluster where exactly one replica lives on each of the three USSs: | ||
|
|
||
| ```sql | ||
| ALTER RANGE default CONFIGURE ZONE USING | ||
| num_replicas = 3, | ||
| constraints = '{"+uss=uss1": 1, "+uss=uss2": 1, "+uss=uss3": 1}'; | ||
| ``` | ||
|
|
||
| ### Explanation of the Parameters: | ||
| * `num_replicas = 3`: Tells CockroachDB to keep 3 copies of each range. | ||
| * `constraints`: A JSON object specifying per-replica constraints. Do note that specifying this might not always be necessary depending on your deployment. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, be more precise on the case when it would not be necessary. |
||
| * `"+uss=uss1": 1` tells CockroachDB that exactly one replica must be located on nodes matching the locality `uss=uss1`. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InterUSS recommends those keys, however, users may already be using other keys (ie region, zone).
Can you please add a note on what they should do if it was the case ?