Cassandra: Providing atomicity and preventing "dirty reads" at the same time -


i need atomically insert multiple rows in cassandra table have different partition keys. @ same time, need make sure each query state of data user updating/inserting correct (so in case of race condition data doesn't messed up). example, db structure is:

create table test(     id uuid,     userid uuid,     address text,     primary key ((id), userid) ); 

when inserting rows, need make sure each of them pk doesn't exist in database, don't want accidentally overwrite data (cassandra that). purpose, lightweight transactions exist, can add if not exists clause , done. problem have several such inserts should either succeed or none of them. following solution doesn't work:

begin batch    insert test(id, userid, address) values(50fcdfd9-7f61-11e5-9c9d-a0999b0af139, daf38231-eab1-4cd3-ae31-8d28d15c762b, 'addr1') if not exists;    insert test(id, userid, address) values(9c26fcc0-0f82-472c-8e83-01b90bed60cc, 0d1a91c4-780a-4bc6-9c12-f2976cb7b3ef, 'addr2') if not exists; apply batch; 

the emitted error is: batch conditions cannot span multiple partitions. documentation says without offering workaround. there way enforce atomicity , consistency of kind on database layer? understand acid principle cannot guaranteed cassandra, can't find answer why restriction batch statements classified error rather warning? can serve workaround problem?

ideas , understanding cassandra philosophy appreciated


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -