cockroachdb / docs

CockroachDB user documentation
https://cockroachlabs.com/docs
Creative Commons Attribution 4.0 International
187 stars 453 forks source link

replication controls inheritance note incorrect #18816

Open annrpom opened 1 month ago

annrpom commented 1 month ago

We have this little note at the bottom of the replication zone variables subtitle here that states:

image

A partition will inherit from its parent index

Jira issue: DOC-10922

annrpom commented 1 month ago

Here is an example of the inheritance (on a 9 node cluster):

root@127.0.0.1:26257/movr> CREATE TABLE test(i INT PRIMARY KEY, j INT) PARTITION BY LIST (i) (                                                  
                        ->   PARTITION one_and_five    VALUES IN (1, 5)                                                                         
                        -> );                                                                                                                   
CREATE TABLE

root@127.0.0.1:26257/movr> ALTER PARTITION one_and_five OF TABLE test CONFIGURE ZONE USING gc.ttlseconds = 10;                                  
CONFIGURE ZONE 1

Time: 73ms total (execution 73ms / network 0ms)

root@127.0.0.1:26257/movr> ALTER INDEX test@test_pkey CONFIGURE ZONE USING num_replicas = 4;                                                    
CONFIGURE ZONE 1

Time: 204ms total (execution 204ms / network 0ms)

-- Looking at the partition, at /Table/112/1/1, we see that the amount of replicas it has is what we set for its parent index:
root@127.0.0.1:26257/movr> select replicas from crdb_internal.ranges where start_pretty = '/Table/112/1/1';                                     
  replicas
-------------
  {1,2,4,7}
(1 row)

Time: 149ms total (execution 148ms / network 0ms)

-- To emphasize this, let's set the amount of replicas on the table to be a different number:
root@127.0.0.1:26257/movr> alter table test configure zone using num_replicas = 7;                                                              
CONFIGURE ZONE 1

-- And we see that the amount of replicas on the table is:
root@127.0.0.1:26257/movr> select replicas from crdb_internal.ranges where start_pretty = '/Table/112';                                         
     replicas
-------------------
  {1,3,4,5,6,7,9}
(1 row)

Time: 156ms total (execution 156ms / network 0ms)

-- But the one for our partition has stayed the same:
root@127.0.0.1:26257/movr> select replicas from crdb_internal.ranges where start_pretty = '/Table/112/1/1';                                     
  replicas
-------------
  {1,2,4,7}
(1 row)

Time: 153ms total (execution 153ms / network 0ms)