liveBook · Manning

Quorum consistency

As explained in ScyllaDB in Action

Quorum consistency is a distributed consistency level in which an operation requires acknowledgments from a quorum of replicas.

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

How ScyllaDB in Action covers it

How deep it goes
Defines majority responses, demonstrates one-node failure, and explains read-write interactions, while deferring repair details.
Examples
Uses a three-node Docker cluster, a stopped node, quorum queries, and Python prepared statements configured with LOCAL_QUORUM.
What it assumes
Assumes familiarity with replicated nodes and queries while teaching majority responses, replica counts, and query-level settings.
What you can do after
Operate/configure ScyllaDB queries with quorum settings and test continued service after one replica fails.
How it connects
Connects replication factor, consistency levels, read-your-writes consistency, stale data, SERIAL consistency, Paxos, and linearizability.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.