You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='test' AND TABLE_NAME = 't'").Check(testkit.Rows(`def test t x`))
599
606
tk.MustExec("create table t_range_p(id int) placement policy x partition by range(id) ("+
Copy file name to clipboardexpand all lines: docs/design/2020-06-24-placement-rules-in-sql.md
+21
Original file line number
Diff line number
Diff line change
@@ -413,6 +413,26 @@ If a table is imported when `tidb_placement_mode='IGNORE'`, and the placement po
413
413
414
414
The default value for `tidb_placement_mode` is `STRICT`. The option is an enum, and in future we may add support for a `WARN` mode.
415
415
416
+
417
+
#### Survival preference
418
+
419
+
Some important data may need to store multiple copies across availability zones, so as to have high disaster recovery survivability, such as region-level survivability, `SURVIVAL_PREFERENCES` can provide survivability preference settings.
420
+
421
+
The following example sets a constraint that the data try to satisfy the Survival Preferences setting:
422
+
423
+
```sql
424
+
CREATE PLACEMENT POLICY multiregion
425
+
follower=4
426
+
PRIMARY_REGION="region1"
427
+
SURVIVAL_PREFERENCES="[region, zone]";
428
+
```
429
+
430
+
For tables with this policy set, the data will first meet the survival goal of cross-region data isolation, and then ensure the survival goal of cross-zone data isolation.
431
+
432
+
> **Note:**
433
+
>
434
+
> `SURVIVAL_PREFERENCES` is equivalent to `LOCATION_LABELS` in PD. For more information, please refer to [Replica scheduling by topology label](https://docs.pingcap.com/tidb/dev/schedule-replicas-by-topology-labels#schedule-replicas-by-topology-labels).
435
+
416
436
#### Ambiguous and edge cases
417
437
418
438
The following two policies are not identical:
@@ -491,6 +511,7 @@ In this case the default rules will apply to placement, and the output from `SHO
491
511
-`FOLLOWER_CONSTRAINTS`
492
512
-`LEARNER_CONSTRAINTS`
493
513
-`PLACEMENT POLICY`
514
+
-`SURVIVAL_PREFERENCE`
494
515
495
516
For a more complex rule using partitions, consider the following example:
0 commit comments