I recently started working with Cassandra and I was reading more about retry policies and consistency level and I think I understood basics of it.
I am just confuse on what retry policy makes more sense to use for my below scenario.
We have a 6 nodes cluster all in one dc with RF as 3 and we read/write as local quorum. My confusion is does it make sense to use DowngradingConsistencyRetryPolicy
here for my use case or I should just stick to DefaultRetryPolicy
here?
Can someone explain difference between those two with some examples so that I can understand when to use what? Also what retry policy is recommended to use here.
I recommend to read Developing applications with DataStax drivers guide first.
Retry policies allow you to repeat the action. This decision should be based on the type of the query itself, and based on the business logic. For example, some applications always require quorum or local quorum, because they couldn't afford data inconsistency. Some applications could be less picky, and prefer the higher availability to the data consistency, or disk of losing data - in this case, downgrading policy could allow to write data with local one, instead of local quorum. But in this case you risk losing the data (like, node that accepted write is completely lost with all data).
In most cases it's recommended to stick to the default policy, but mark your queries as idempotent (of course if they are... you can also set this flag on the connection level). Idempotent queries - all queries those re-execution won't change compared to the executing only once. This covers all "normal" inserts, deletes, most of updates (except append/prepend to the list). LWTs are not idempotent!