yugabyte/yugabyte-db

[Phase 1][YSQL][Colocation] Alter table fails on colocated table

ndeodhar opened this issue · 3 comments

Jira Link: [DB-391](https://yugabyte.atlassian.net/browse/DB-391)
Alter table fails on colocated DB:

yugabyte=# create database codb with colocated=true;
CREATE DATABASE
yugabyte=# \c codb
You are now connected to database "codb" as user "yugabyte".
codb=# create table test(a int primary key);
CREATE TABLE
codb=# insert into test select generate_series(1,100);
INSERT 0 100
codb=# alter table test add column b int;
ERROR:  Timed out: Timed out waiting for AlterTable
jaki commented

The overall issue is that alter table doesn't handle non-primary tables of tablets well. Here are some details to fix it, going in time order:

  1. master AsyncAlterTable should take table param (otherwise, it always uses tablet's primary table)
  2. ChangeMetadataRequestPB probably needs some alter_table_id field
  3. Some modifications to TabletService
  4. Some modifications to Tablet
  5. Some modifications to RaftGroupMetadata
  6. master HandleTabletSchemaVersionReport should take table param (otherwise, it always uses tablet's primary table)

See https://github.com/jaki/yugabyte-db/tree/colo-alter-table for partial work.

Validate this for tablegroups as well

Verified - this has been fixed, ALTER works for both means of colocation