I am using cassandra.
I have two column families A and B. Both the column families have same data but both have different primary keys. Now I am using a batch statement to update the rows in these two tables.
Table schema is as follows:
Primary Key of table A [id1(partition key) id2(partition key) id3(clustering key)]
Primary Key of table B [id1(partition key) id2(partition key) state(clustering key) id3(clustering key)]
I want to update the state of both the tables. State is cluster key in B and in table A, it is simple column.
What I do is fetch the state from A and consider it as old state.
Then in batch what I do is first delete row from table A, then Delete row from Table B, Insert new row in table A and the insert new row in table B.
Note : Using the old state that is fetched from A, I make primary key of B and then delete from B and the insert new row in B.
It is working fine but for parallel requests it is not. If 2 requests are coming for same primary key from 2 different instances, then I am getting the problem. Table B gets the two entries with old and new state.
So How can I solve that in cassandra?