database - Cassandra requires restart when ALTER TABLE ADD COLUMN to table with existing data records -


database: cassandra 2.1.2 (single node)

database driver: cassandra driver 2.1.6.

application: dropwizard 0.7.1

i have simple table in database:

cqlsh:ugc> desc table person;  create table abc.person (     id uuid primary key ) bloom_filter_fp_chance = 0.01     , caching = '{"keys":"all", "rows_per_partition":"none"}'     , comment = ''     , compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.sizetieredcompactionstrategy', 'max_threshold': '32'}     , compression = {'sstable_compression': 'org.apache.cassandra.io.compress.lz4compressor'}     , dclocal_read_repair_chance = 0.1     , default_time_to_live = 0     , gc_grace_seconds = 864000     , max_index_interval = 2048     , memtable_flush_period_in_ms = 0     , min_index_interval = 128     , read_repair_chance = 0.0     , speculative_retry = '99.0percentile'; 

and table contains data:

cqlsh:ugc> select * person;   id --------------------------------------  bf56c8b1-ed0b-44d6-bd45-0d55dd73fbe0 

in dropwizard application, have mapped object:

@table(name = "person") public class person {     @partitionkey     @column(name ="id")     uuid id;       public uuid getid() {         return id;     }      public void setid(uuid id) {         this.id = id;     } } 

everything works well. able retrieve data dropwizard application. however, when

1) add new column 'name' table

cqlsh:ugc> alter table abc.person add name text;  cqlsh:ugc> desc table person;  create table abc.person (     id uuid primary key,     name text ) bloom_filter_fp_chance = 0.01     , caching = '{"keys":"all", "rows_per_partition":"none"}'     , comment = ''     , compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.sizetieredcompactionstrategy', 'max_threshold': '32'}     , compression = {'sstable_compression': 'org.apache.cassandra.io.compress.lz4compressor'}     , dclocal_read_repair_chance = 0.1     , default_time_to_live = 0     , gc_grace_seconds = 864000     , max_index_interval = 2048     , memtable_flush_period_in_ms = 0     , min_index_interval = 128     , read_repair_chance = 0.0     , speculative_retry = '99.0percentile';  cqlsh:ugc> select * person;   id                                   | name --------------------------------------+------  bf56c8b1-ed0b-44d6-bd45-0d55dd73fbe0 | null 

2) update person object map new column

@table(name = "person") public class person {     @partitionkey     @column(name ="id")     uuid id;       public uuid getid() {         return id;     }      public void setid(uuid id) {         this.id = id;     }      @column(name = "name")     string name;      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     } } 

3) restart dropwizard application

the application throws exception:

java.lang.illegalargumentexception: "name" not column defined in metadata 

error looks it's saying model trying map column 'name' doesn't exist in database table, when in fact it's there database point of view.

but, if restart database, seems fix issue.

it looks like, alter table requires database restart when table contains existing records. issue not occur when table empty , new column added (does not require restart). couldn't find documentation [http://docs.datastax.com/en/cql/3.0/cql/cql_reference/alter_table_r.html] deals situation.

question:

is there way can alter table without restarting database? if so, how do it? if not, can explain why database restart required?

on side, don't need restart db update schema. don't know how restart application. suggest stop application , search if process still running application , start application.

it seems connection db not break while restarting application, , stop db force connection stoped, change work.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -