yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.86k stars 1.05k forks source link

[DocDB][xCluster][DDL Changes] RENAME TO erroring out with xCluster DDL changes #14811

Open Arjun-yb opened 1 year ago

Arjun-yb commented 1 year ago

Jira Link: DB-4122

Description

Version: `2.17.1.0-b122'

Steps:

  1. Create database and table on both sides. create table employees(id int, name text);
  2. Setup replication
  3. Load data and validate data at both sides
  4. Rename table at both sides alter table employees rename to new_table;
  5. Alter table at source and add a column. alter table new_table add column age int;
  6. Rename table at source alter table new_table rename to old_table;
  7. Rename table at target
    
    demo=# alter table new_table rename to old_table;
    ERROR:  Illegal state: New Schema not compatible with XCluster Producer Schema:
    new={Schema [

] properties: contain_counters: false is_transactional: false consistency_level: STRONG use_mangled_column_name: false is_ysql_catalog_table: false retain_delete_markers: false partitioning_version: 1} producer={Schema [ 0:ybrowid[binary NOT NULL PARTITION KEY], 1:id[int32 NULLABLE NOT A PARTITION KEY], 2:name[string NULLABLE NOT A PARTITION KEY], 3:age[int32 NULLABLE NOT A PARTITION KEY] ] properties: contain_counters: false is_transactional: true consistency_level: STRONG use_mangled_column_name: false is_ysql_catalog_table: false retain_delete_markers: false partitioning_version: 1}


8. Now alter table at target and add column 
`alter table new_table add column age int;`
9. Now rename table at target and check the behaviour
`alter table new_table rename to old_table;`

**Actual**:
1. After Step#7:  It is displaying empty Schema for target.
2. After Step#9: it throws `ERROR:  relation "old_table" already exists`

**Expected**:
1. After Step#7: It should show current target table's schema
2. After Step#9: It should not throw an error - It should rename it correctly

**Note**: Workaround for Step#9 is exit from the current session and reconnect and try Step#9.
nspiegelberg commented 1 year ago

Step#9 should be fixed after #13358 is committed.