Ok, if you want that behaviour, a generic retry policy won't work. You should build a custom one, something like:
const consistency = cassandra.types.consistencies;
YourCustomRetryPolicy.prototype.onUnavailable = function (requestInfo, consistency, required, alive) { if (requestInfo.nbRetry > 0) { return this.rethrowResult(); } if (consistency === consistency.localOne) {
return this.retryResult(consistency.localQuorum, false);
}
return this.retryResult(undefined, false);};Disclaimer: this is a code sample, not intended for production use.
That way, it will be retried with LOCAL_QUORUM the second time on the next host. Which is the "next host" **depends on the load balancing policy (lbp)**, you should use a lbp that selects remote replicas after local replicas could not be reached, something like:
const DCAwareRoundRobinPolicy = cassandra.policies.loadBalancing.DCAwareRoundRobinPolicy;
const TokenAwarePolicy = cassandra.policies.loadBalancing.TokenAwarePolicy;// Use 6 remote nodes for failover
const lbp = new TokenAwarePolicy(new DCAwareRoundRobinPolicy('my-local-dc', 6));
const client = new cassandra.Client({ policies: { loadBalancing : lbp },
contactPoints: yourContactPoints
});
Hope it helps,
Jorge