Apoorv
Apoorv

Reputation: 2735

Are triggers in cassandra atomic?

I want to update a counter column of table B whenever a row gets inserted in table A. Batch operations do not allow mixing counter and non-counter updates. So I was wondering if I could implement a trigger that would do this. This would only be useful if triggers are atomic, and by that I mean that there will not be any condition where the row in table B gets inserted but trigger is not fired, or vice versa.

Upvotes: 1

Views: 203

Answers (1)

RussS
RussS

Reputation: 16576

Triggers only fire on the coordinator node. This may sound like you would be safe, but this is actually still not atomic or idempotent because the client connection is always allowed to retry if it thinks there was a failure. That means if you write and the client doesn't think the write succeeded then it is free to retry against a different node. This means you could end up firing the same trigger twice for the same row.

Upvotes: 2

Related Questions