ScyllaDB Documentation Logo Documentation
  • Server
    • ScyllaDB Open Source
    • ScyllaDB Enterprise
    • ScyllaDB Alternator
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
Download
Menu
ScyllaDB Docs Scylla Rust Driver Making queries Schema agreement

Schema agreement¶

Sometimes after performing queries some nodes have not been updated so we need a mechanism that checks if every node have agreed schema version. There are four methods in Session that assist us. Every method raise QueryError if something goes wrong, but they should never raise any errors, unless there is a DB or connection malfunction.

Checking schema version¶

Session::fetch_schema_version returns an Uuid of local node’s schema version.

println!("Local schema version is: {}", session.fetch_schema_version().await?);

Awaiting schema agreement¶

Session::await_schema_agreement returns a Future that can be awaited on as long as schema is not in an agreement.

session.await_schema_agreement().await?;

Awaiting with timeout¶

We can also set timeout in milliseconds with Session::await_timed_schema_agreement. It takes one argument, an std::time::Duration value that tells how long our driver should await for schema agreement. If the timeout is met the return value is false otherwise it is true.

if session.await_timed_schema_agreement(Duration::from_secs(5)).await? { // wait for 5 seconds
    println!("SCHEMA AGREED");
} else {
    println!("SCHEMA IS NOT IN AGREEMENT - TIMED OUT");
}

Checking for schema interval¶

If schema is not agreed driver sleeps for a duration before checking it again. Default value is 200 milliseconds but it can be changed with SessionBuilder::schema_agreement_interval.

SessionBuilder::new()
    .known_node("127.0.0.1:9042")
    .schema_agreement_interval(Duration::from_secs(1))
    .build()
    .await?;

Checking if schema is in agreement now¶

If you want to check if schema is in agreement now without retrying after failure you can use Session::check_schema_agreement function.

if session.check_schema_agreement().await? { 
    println!("SCHEMA AGREED");
} else {
    println!("SCHEMA IS NOT IN AGREEMENT");
}
PREVIOUS
USE keyspace
NEXT
Lightweight transaction (LWT) query
Scylla Rust Driver
  • main
    • main
  • Scylla Rust Driver
  • Quick Start
    • Creating a project
    • Connecting and running a simple query
    • Running Scylla using Docker
  • Connecting to the cluster
    • Compression
    • Authentication
    • TLS
  • Making queries
    • Simple query
    • Query values
    • Query result
    • Prepared query
    • Batch statement
    • Paged query
    • USE keyspace
    • Schema agreement
    • Lightweight transaction (LWT) query
    • Query timeouts
  • Execution profiles
    • Creating a profile and setting it
    • All options supported by a profile
    • Priorities of execution settings
    • Remapping execution profile handles
  • Data Types
    • Bool, Tinyint, Smallint, Int, Bigint, Float, Double
    • Ascii, Text, Varchar
    • Counter
    • Blob
    • Inet
    • Uuid, Timeuuid
    • Date
    • Time
    • Timestamp
    • Duration
    • Decimal
    • Varint
    • List, Set, Map
    • Tuple
    • User defined types
  • Load balancing
    • DefaultPolicy
  • Retry policy configuration
    • Fallthrough retry policy
    • Default retry policy
    • Downgrading consistency retry policy
  • Speculative execution
    • Simple speculative execution
    • Percentile speculative execution
  • Driver metrics
  • Logging
  • Query tracing
    • Tracing a simple/prepared/batch query
    • Tracing a paged query
    • Tracing Session::prepare
    • Query Execution History
  • Schema
  • Create an issue
  • Edit this page

On this page

  • Schema agreement
    • Checking schema version
    • Awaiting schema agreement
    • Awaiting with timeout
    • Checking for schema interval
    • Checking if schema is in agreement now
Logo
Docs Contact Us About Us
Mail List Icon Slack Icon Forum Icon
© 2023, ScyllaDB. All rights reserved.
Last updated on 22 March 2023.
Powered by Sphinx 4.3.2 & ScyllaDB Theme 1.3.5