Skip to content

Commit 3b89516

Browse files
committed
cluster: set serial consistency to None by default
The default serial consistency in the Rust driver is LocalSerial, which is different to Any in the CPP driver. This commit sets the default serial consistency to None, which is equivalent to Any. This makes CPP-Rust driver consistent with the CPP driver in terms of the default serial consistency. Note: Rust driver purposefully set the default serial consistency to LocalSerial instead of None. The rationale taken from the issue (scylladb/scylla-rust-driver#277): > Using lightweight transactions in CQL requires setting an additional > consistency level, the so called serial consistency level, on top of > the regular one. The serial consistency level can only take two > values: SERIAL and LOCAL_SERIAL. There's currently no default, so > using lwt results in an error message: `Consistency level for LWT is > missing for a request with conditions`. We should consider picking > a sensible default value in order to improve the user experience > of the driver. Considering this, we should consider changing the default serial consistency in CPP-Rust driver to LocalSerial, too. This commit finishes corrections made to consistency handling.
1 parent f945d40 commit 3b89516

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

scylla-rust-wrapper/src/cluster.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ use crate::cass_compression_types::CassCompressionType;
4040
// According to `cassandra.h` the defaults for
4141
// - consistency for statements is LOCAL_ONE,
4242
const DEFAULT_CONSISTENCY: Consistency = Consistency::LocalOne;
43+
// - serial consistency for statements is ANY, which corresponds to None in Rust Driver.
44+
const DEFAULT_SERIAL_CONSISTENCY: Option<SerialConsistency> = None;
4345
// - request client timeout is 12000 millis,
4446
const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_millis(12000);
4547
// - fetching schema metadata is true
@@ -174,6 +176,7 @@ pub(crate) fn build_session_builder(
174176
pub unsafe extern "C" fn cass_cluster_new() -> CassOwnedExclusivePtr<CassCluster, CMut> {
175177
let default_execution_profile_builder = ExecutionProfileBuilder::default()
176178
.consistency(DEFAULT_CONSISTENCY)
179+
.serial_consistency(DEFAULT_SERIAL_CONSISTENCY)
177180
.request_timeout(Some(DEFAULT_REQUEST_TIMEOUT));
178181

179182
// Default config options - according to cassandra.h

0 commit comments

Comments
 (0)