Skip to content

2.25.2.0-b308

@SrivastavaAnubhav SrivastavaAnubhav tagged this 09 Apr 23:11
Summary:
This diff disallows the creation of tablespaces with duplicate placement blocks, such as the following:
```
CREATE TABLESPACE rf2 WITH ( replica_placement= $$
{
    "num_replicas": 2,
    "placement_blocks": [
{ "cloud": "cloud1", "region": "datacenter1", "zone": "rack1"   , "min_num_replicas": 1 },
{ "cloud": "cloud1", "region": "datacenter1", "zone": "rack1"   , "min_num_replicas": 1 }
    ]
} $$) ;
```

The correct syntax is:
```
CREATE TABLESPACE rf2 WITH ( replica_placement= $$
{
    "num_replicas": 2,
    "placement_blocks": [
{ "cloud": "cloud1", "region": "datacenter1", "zone": "rack1"   , "min_num_replicas": 2 }
    ]
} $$) ;
```

This diff moves tablespace validation to its own function so we can ignore it when loading the tablespaces, which makes upgrades and adding new checks possible. A future diff will also use this function for validating the replication infos created by the yb-admin CLI commands.
Existing entries in sys_catalog are not being migrated, but those tablespaces are not working right now anyways. We will print a error log, however.

This diff also removes a check that extra keys cause creating a tablespace to fail, since this might happen on upgrades if a new field is added.

The validation checks are guarded by a flag (`enable_tablespace_validation`). Users might be need to set this to `false` if restoring a cluster with old tablespaces that do not pass validation.

**Upgrade/Rollback safety:**
Tablespaces that do not pass validation will still be loaded. We only use the checks when creating tablespaces.

Jira: DB-12324

Test Plan: `./yb_build.sh release --cxx-test common_tablespace_parser-test --gtest_filter TablespaceParserTest.*`

Reviewers: jhe

Reviewed By: jhe

Subscribers: yql, ybase, ycdcxcluster

Differential Revision: https://phorge.dev.yugabyte.com/D41852
Assets 2
Loading