yugabyte / yugabyte-db

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

[YCQL] Allow altering a table from non-transactional to transactional #11000

Open tylarb opened 2 years ago

tylarb commented 2 years ago

Jira Link: DB-701

Description

Is it possible to allow ALTER TABLE syntax to allow a table to move from non-transaction to transactional?

example:

ycqlsh> CREATE TABLE test.i ( i int, PRIMARY KEY (i) )  with default_time_to_live = 0 AND tablets = 48 AND transactions = {'enabled': 'false'};

ycqlsh> alter table test.i with transactions = {'enabled': 'true'};
SyntaxException: Invalid SQL Statement. syntax error, unexpected '{'
alter table test.i with transactions = {'enabled': 'true'};
                                       ^
 (ql error -11)
deeps1991 commented 1 year ago

From the notes on the corresponding slack thread, the steps to support this include:

  1. Allow changing the metadata of the table from non-transactional to transactional (through ALTER API)
  2. Use a variation of current Alter Table flow for this - change metadata on the tablets and increase schema version
  3. For this specific alter, we should also spin up the RocksDB for the intent database for every tablet
  4. We should make sure that the tablet does not process any IO until this initialisation is complete
es1024 commented 1 year ago

Additional point of notice: the global transaction table needs to be created if it's not already present -- this is normally done when the first transactional table is created, but the alter here may happen without any existing transactional tables.

bmatican commented 1 year ago

Great point, Eric!