liveBook · Manning

Speculative retry

As explained in ScyllaDB in Action

A speculative retry is a database-driver technique that reissues an unfinished request after a delay to reduce response time when the original may be stalled.

A speculative retry reissues an unfinished database query after a delay. The driver races the original and retry, returning whichever completes first, which can reduce latency when a node or network connection is temporarily degraded. section 10.5.3

Use speculative retries to trade additional request load for faster responses:

  • Mark each eligible query as idempotent before enabling speculative execution; repeating it must leave the cluster in the same state. section 10.5.3
  • Avoid non-idempotent operations such as appending to a list or generating an ID with uuid(), because retries can create repeated or different results. section 10.5.3
  • Keep retry settings conservative when the cluster is already overloaded; extra attempts increase traffic and may worsen the situation. section 10.5.3

Driver configuration

A Python driver can use ConstantSpeculativeExecutionPolicy with a 0.1-second interval and two maximum attempts. The application then marks selected prepared statements, such as ALL_AUTHORS, GET_ARTICLE, and GET_AUTHOR, as idempotent.

How ScyllaDB in Action covers it

How deep it goes
Explains timing, response racing, idempotency, and load trade-offs, then stops short of detailed retry tuning.
Examples
Uses list appends, uuid(), delayed query races, and Python driver settings for selected prepared statements.
What it assumes
Assumes query and driver familiarity while teaching idempotency through concrete database-operation examples.
What you can do after
Configure speculative execution through the Python driver and safely select queries that can be retried.
How it connects
Connects idempotency with database queries, prepared statements, driver execution policies, and node failure detection.

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.