Question

I want to update multiple rows in 2 CF's. I don't care about the order they get updated ? But is it guaranteed that if one gets succeeded then eventually others will get too if some C* node fails in between ?

Hector BatchMutation class use batch update or atomic batch update as these are two separate things.

Was it helpful?

Solution

You should use an atomic batch in CQL3. This guarantees that either the entire batch succeeds or the entire batch fails. An example from the CQL3 docs:

BEGIN BATCH
  INSERT INTO users (userid, password, name) VALUES ('user2', 'ch@ngem3b', 'second user');
  UPDATE users SET password = 'ps22dhds' WHERE userid = 'user3';
  INSERT INTO users (userid, password) VALUES ('user4', 'ch@ngem3c');
  DELETE name FROM users WHERE userid = 'user1';
APPLY BATCH;

The Hector BatchMutation class uses the Thrift operation batch_mutate. This is weaker than atomic_batch_mutate, which is the Thrift equivalent of the above. batch_mutate is only atomic for updates on the same key (can be different CFs though), whereas atomic_batch_mutate is atomic on all updates. I don't think Hector has implemented atomic_batch_mutate so you will need to move to CQL3 and a CQL3-capable driver e.g. DataStax's java driver.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top