@@ -202,6 +202,24 @@ DATABASE db ALTER DATABASE db CONFIGURE ZONE USING
202
202
voter_constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 2}',
203
203
lease_preferences = '[[+region=ap-southeast-2], [+region=ca-central-1]]'
204
204
205
+ # All of the table zone configs are the result of an implicit super region. To
206
+ # help make sense of those, dump out the current primary and secondary regions
207
+ # in the database.
208
+ query TT
209
+ SELECT
210
+ region,
211
+ CASE
212
+ WHEN "primary" THEN 'primary'
213
+ WHEN "secondary" THEN 'secondary'
214
+ ELSE 'other'
215
+ END AS role
216
+ FROM [SHOW REGIONS FROM DATABASE db]
217
+ ORDER BY region;
218
+ ----
219
+ ap-southeast-2 primary
220
+ ca-central-1 secondary
221
+ us-east-1 other
222
+
205
223
# Verify that the zone configuration on the table is expected.
206
224
query TT
207
225
SHOW ZONE CONFIGURATION FOR TABLE db.rbt_in_primary
@@ -212,7 +230,7 @@ TABLE db.public.rbt_in_primary ALTER TABLE db.public.rbt_in_primary CONFIGURE Z
212
230
gc.ttlseconds = 14400,
213
231
num_replicas = 5,
214
232
num_voters = 5,
215
- constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 2 , +region=us-east-1: 1}',
233
+ constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1 , +region=us-east-1: 1}',
216
234
voter_constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 2}',
217
235
lease_preferences = '[[+region=ap-southeast-2], [+region=ca-central-1]]'
218
236
@@ -225,7 +243,7 @@ TABLE db.public.rbt_in_us_east ALTER TABLE db.public.rbt_in_us_east CONFIGURE Z
225
243
gc.ttlseconds = 14400,
226
244
num_replicas = 5,
227
245
num_voters = 5,
228
- constraints = '{+region=ap-southeast-2: 2 , +region=ca-central-1: 1, +region=us-east-1: 1}',
246
+ constraints = '{+region=ap-southeast-2: 1 , +region=ca-central-1: 1, +region=us-east-1: 1}',
229
247
voter_constraints = '{+region=ca-central-1: 2, +region=us-east-1: 2}',
230
248
lease_preferences = '[[+region=us-east-1], [+region=ca-central-1]]'
231
249
@@ -252,7 +270,7 @@ PARTITION "us-east-1" OF TABLE db.public.rbr ALTER PARTITION "us-east-1" OF TAB
252
270
gc.ttlseconds = 14400,
253
271
num_replicas = 5,
254
272
num_voters = 5,
255
- constraints = '{+region=ap-southeast-2: 2 , +region=ca-central-1: 1, +region=us-east-1: 1}',
273
+ constraints = '{+region=ap-southeast-2: 1 , +region=ca-central-1: 1, +region=us-east-1: 1}',
256
274
voter_constraints = '{+region=ca-central-1: 2, +region=us-east-1: 2}',
257
275
lease_preferences = '[[+region=us-east-1], [+region=ca-central-1]]'
258
276
@@ -265,7 +283,7 @@ PARTITION "ap-southeast-2" OF TABLE db.public.rbr ALTER PARTITION "ap-southeast
265
283
gc.ttlseconds = 14400,
266
284
num_replicas = 5,
267
285
num_voters = 5,
268
- constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 2 , +region=us-east-1: 1}',
286
+ constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1 , +region=us-east-1: 1}',
269
287
voter_constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 2}',
270
288
lease_preferences = '[[+region=ap-southeast-2], [+region=ca-central-1]]'
271
289
@@ -312,7 +330,7 @@ TABLE db.public.rbt_in_us_east ALTER TABLE db.public.rbt_in_us_east CONFIGURE Z
312
330
gc.ttlseconds = 14400,
313
331
num_replicas = 5,
314
332
num_voters = 5,
315
- constraints = '{+region=ap-southeast-2: 2 , +region=ca-central-1: 1, +region=us-east-1: 1}',
333
+ constraints = '{+region=ap-southeast-2: 1 , +region=ca-central-1: 1, +region=us-east-1: 1}',
316
334
voter_constraints = '{+region=ca-central-1: 2, +region=us-east-1: 2}',
317
335
lease_preferences = '[[+region=us-east-1], [+region=ca-central-1]]'
318
336
@@ -339,7 +357,7 @@ PARTITION "us-east-1" OF TABLE db.public.rbr ALTER PARTITION "us-east-1" OF TAB
339
357
gc.ttlseconds = 14400,
340
358
num_replicas = 5,
341
359
num_voters = 5,
342
- constraints = '{+region=ap-southeast-2: 2 , +region=ca-central-1: 1, +region=us-east-1: 1}',
360
+ constraints = '{+region=ap-southeast-2: 1 , +region=ca-central-1: 1, +region=us-east-1: 1}',
343
361
voter_constraints = '{+region=ca-central-1: 2, +region=us-east-1: 2}',
344
362
lease_preferences = '[[+region=us-east-1], [+region=ca-central-1]]'
345
363
@@ -352,7 +370,7 @@ PARTITION "ap-southeast-2" OF TABLE db.public.rbr ALTER PARTITION "ap-southeast
352
370
gc.ttlseconds = 14400,
353
371
num_replicas = 5,
354
372
num_voters = 5,
355
- constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 2 , +region=us-east-1: 1}',
373
+ constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1 , +region=us-east-1: 1}',
356
374
voter_constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 2}',
357
375
lease_preferences = '[[+region=ap-southeast-2], [+region=ca-central-1]]'
358
376
@@ -427,6 +445,98 @@ PARTITION "ca-central-1" OF TABLE db.public.rbr ALTER PARTITION "ca-central-1"
427
445
voter_constraints = '{+region=ca-central-1: 2}',
428
446
lease_preferences = '[[+region=ca-central-1]]'
429
447
448
+ # Ensure that the implicit super region is updated now that the secondary region
449
+ # was dropped. We will dump the regions and role so that we can more easily
450
+ # understand the table zone configs that follow.
451
+ query TT
452
+ SELECT
453
+ region,
454
+ CASE
455
+ WHEN "primary" THEN 'primary'
456
+ WHEN "secondary" THEN 'secondary'
457
+ ELSE 'other'
458
+ END AS role
459
+ FROM [SHOW REGIONS FROM DATABASE db]
460
+ ORDER BY region;
461
+ ----
462
+ ap-southeast-2 primary
463
+ ca-central-1 other
464
+ us-east-1 other
465
+
466
+ query TT
467
+ SHOW ZONE CONFIGURATION FOR TABLE db.rbt_in_us_east
468
+ ----
469
+ TABLE db.public.rbt_in_us_east ALTER TABLE db.public.rbt_in_us_east CONFIGURE ZONE USING
470
+ range_min_bytes = 134217728,
471
+ range_max_bytes = 536870912,
472
+ gc.ttlseconds = 14400,
473
+ num_replicas = 5,
474
+ num_voters = 5,
475
+ constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 1, +region=us-east-1: 1}',
476
+ voter_constraints = '{+region=us-east-1: 2}',
477
+ lease_preferences = '[[+region=us-east-1]]'
478
+
479
+ query TT
480
+ SHOW ZONE CONFIGURATION FOR TABLE db.rbt_in_ca_central
481
+ ----
482
+ TABLE db.public.rbt_in_ca_central ALTER TABLE db.public.rbt_in_ca_central CONFIGURE ZONE USING
483
+ range_min_bytes = 134217728,
484
+ range_max_bytes = 536870912,
485
+ gc.ttlseconds = 14400,
486
+ num_replicas = 5,
487
+ num_voters = 5,
488
+ constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 1, +region=us-east-1: 1}',
489
+ voter_constraints = '{+region=ca-central-1: 2}',
490
+ lease_preferences = '[[+region=ca-central-1]]'
491
+
492
+ # Add a different secondary to confirm zone config adjusts based on the secondary.
493
+ statement ok
494
+ ALTER DATABASE db SET SECONDARY REGION "us-east-1"
495
+
496
+ # Dump the regions and role so that we can understand table zone configs easier.
497
+ query TT
498
+ SELECT
499
+ region,
500
+ CASE
501
+ WHEN "primary" THEN 'primary'
502
+ WHEN "secondary" THEN 'secondary'
503
+ ELSE 'other'
504
+ END AS role
505
+ FROM [SHOW REGIONS FROM DATABASE db]
506
+ ORDER BY region;
507
+ ----
508
+ ap-southeast-2 primary
509
+ ca-central-1 other
510
+ us-east-1 secondary
511
+
512
+ query TT
513
+ SHOW ZONE CONFIGURATION FOR TABLE db.rbt_in_us_east
514
+ ----
515
+ TABLE db.public.rbt_in_us_east ALTER TABLE db.public.rbt_in_us_east CONFIGURE ZONE USING
516
+ range_min_bytes = 134217728,
517
+ range_max_bytes = 536870912,
518
+ gc.ttlseconds = 14400,
519
+ num_replicas = 5,
520
+ num_voters = 5,
521
+ constraints = '{+region=ap-southeast-2: 2, +region=ca-central-1: 1, +region=us-east-1: 1}',
522
+ voter_constraints = '{+region=us-east-1: 2}',
523
+ lease_preferences = '[[+region=us-east-1]]'
524
+
525
+ query TT
526
+ SHOW ZONE CONFIGURATION FOR TABLE db.rbt_in_ca_central
527
+ ----
528
+ TABLE db.public.rbt_in_ca_central ALTER TABLE db.public.rbt_in_ca_central CONFIGURE ZONE USING
529
+ range_min_bytes = 134217728,
530
+ range_max_bytes = 536870912,
531
+ gc.ttlseconds = 14400,
532
+ num_replicas = 5,
533
+ num_voters = 5,
534
+ constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
535
+ voter_constraints = '{+region=ca-central-1: 2, +region=us-east-1: 2}',
536
+ lease_preferences = '[[+region=ca-central-1], [+region=us-east-1]]'
537
+
538
+ statement ok
539
+ ALTER DATABASE db DROP SECONDARY REGION
430
540
431
541
# Verify super region interactions
432
542
statement ok
0 commit comments