Quorum consistency requires a majority of replicas to respond successfully to a query. With three replicas, one node can be unavailable while reads and writes continue. section 1.3.1 section 2.1
Use quorum consistency to balance availability with protection against stale data:
- Set the replication factor to 3 when you want quorum operations to tolerate the loss of one node. section 2.4
- Use quorum for both writes and reads so a majority sees each write and reads can obtain the newest value. section 8.2.2
- Prefer an odd replication factor because equal numbers of replicas can disagree when the replica count is even. section 8.2.2
- Expect ScyllaDB to reconcile stale-value conflicts discovered during quorum reads. section 8.2.2
Testing a failed node
Run a three-node ScyllaDB cluster in Docker, stop one node, and issue quorum queries. With replication factor 3, the remaining nodes should continue serving those queries. section 2.1 section 2.4
Listing 10.26 Setting the consistency level on a prepared statement
from cassandra import ConsistencyLevel
...
def get_db_session():
if 'db' not in g:
...
PREPARED_STATEMENTS[INSERT_ARTICLE_SUMMARIES_BY_SCORE] =
session.prepare(
"""INSERT INTO article_summaries_by_score(
score, id, author_name, image, title
) VALUES (
?, ?, ?, ?, ?
)"""
)
for statement in PREPARED_STATEMENTS.values():
statement.consistency_level = ConsistencyLevel.LOCAL_QUORUM
...
A Python driver example sets prepared statements to LOCAL_QUORUM, while bound statements can override the setting for individual executions. section 10.5.1
