Skip to content

Commit 827c7ff

Browse files
committed
feat(cluster): carry an LSN-versioned read-set on the Calvin TxClass
Add versioned_reads to TxClass so a transaction's point/predicate read observations, each stamped with the responding shard's write-LSN watermark, travel on the replicated Calvin transaction for future commit-time optimistic-concurrency validation. The field is additive (map-encoded with a default) so TxClass bytes already on the sequencer Raft log decode unchanged. Carrying that read identity over the wire requires KeyRepr — row identity within a collection — to be Send + Sync and shared across planes rather than owned by the nodedb crate's Control-Plane types, so it moves to nodedb-types alongside the other plane-neutral wire types. Call sites across nodedb, nodedb-cluster, and nodedb-cluster-tests update to the new import path and threaded constructor argument.
1 parent 2bd7d36 commit 827c7ff

29 files changed

Lines changed: 641 additions & 76 deletions

nodedb-cluster-tests/tests/calvin_3node_normal.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::time::Duration;
2121

2222
use nodedb_cluster::calvin::{
2323
sequencer::{SequencerConfig, new_inbox},
24-
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass},
24+
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass, VersionedReadSet},
2525
};
2626
use nodedb_types::{
2727
TenantId,
@@ -68,6 +68,7 @@ fn make_multishard_txclass() -> (TxClass, u32, u32) {
6868
vec![],
6969
TenantId::new(1),
7070
None,
71+
VersionedReadSet::default(),
7172
)
7273
.expect("valid TxClass");
7374
(tx, va, vb)

nodedb-cluster-tests/tests/calvin_3node_shard_failover.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use std::time::Duration;
4545

4646
use nodedb_cluster::calvin::{
4747
sequencer::{SequencerConfig, new_inbox},
48-
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass},
48+
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass, VersionedReadSet},
4949
};
5050
use nodedb_types::{
5151
TenantId,
@@ -91,6 +91,7 @@ fn make_txclass(surr_a: u32, surr_b: u32) -> TxClass {
9191
vec![],
9292
TenantId::new(1),
9393
None,
94+
VersionedReadSet::default(),
9495
)
9596
.expect("valid TxClass")
9697
}

nodedb-cluster-tests/tests/calvin_e2e_ollp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::time::Duration;
3939

4040
use nodedb_cluster::calvin::{
4141
sequencer::{SequencerConfig, new_inbox},
42-
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass},
42+
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass, VersionedReadSet},
4343
};
4444
use nodedb_types::{
4545
TenantId,
@@ -101,6 +101,7 @@ fn make_ollp_tx_class(
101101
vec![],
102102
TenantId::new(1),
103103
None,
104+
VersionedReadSet::default(),
104105
)
105106
.expect("valid multi-vshard OLLP TxClass")
106107
}

nodedb-cluster-tests/tests/calvin_e2e_pgwire.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::time::Duration;
2222

2323
use nodedb_cluster::calvin::{
2424
sequencer::{SequencerConfig, new_inbox},
25-
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass},
25+
types::{EngineKeySet, ReadWriteSet, SequencedTxn, SortedVec, TxClass, VersionedReadSet},
2626
};
2727
use nodedb_types::{
2828
TenantId,
@@ -74,6 +74,7 @@ fn make_multi_vshard_insert(col_a: &str, col_b: &str) -> TxClass {
7474
vec![],
7575
TenantId::new(1),
7676
None,
77+
VersionedReadSet::default(),
7778
)
7879
.expect("valid TxClass for multi-vshard INSERT")
7980
}

nodedb-cluster-tests/tests/calvin_sequencer_failover.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::time::Duration;
1515

1616
use nodedb_cluster::calvin::{
1717
sequencer::{SequencerConfig, new_inbox},
18-
types::{EngineKeySet, ReadWriteSet, SortedVec, TxClass},
18+
types::{EngineKeySet, ReadWriteSet, SortedVec, TxClass, VersionedReadSet},
1919
};
2020
use nodedb_types::{
2121
TenantId,
@@ -58,6 +58,7 @@ fn make_txclass(surr_a: u32, surr_b: u32) -> TxClass {
5858
vec![],
5959
TenantId::new(1),
6060
None,
61+
VersionedReadSet::default(),
6162
)
6263
.expect("valid TxClass")
6364
}

nodedb-cluster-tests/tests/calvin_sequencer_starvation.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ use std::time::{Duration, Instant};
2323
use nodedb_cluster::calvin::sequencer::config::SequencerConfig;
2424
use nodedb_cluster::calvin::sequencer::inbox::{Inbox, new_inbox};
2525
use nodedb_cluster::calvin::sequencer::validator::validate_batch;
26-
use nodedb_cluster::calvin::types::{EngineKeySet, ReadWriteSet, SortedVec, TxClass};
26+
use nodedb_cluster::calvin::types::{
27+
EngineKeySet, ReadWriteSet, SortedVec, TxClass, VersionedReadSet,
28+
};
2729
use nodedb_types::{
2830
TenantId,
2931
id::{DatabaseId, VShardId},
@@ -67,6 +69,7 @@ fn make_conflicting_tx(col_a: &str, col_b: &str, unique_surr: u32, tenant: u64)
6769
vec![unique_surr as u8],
6870
TenantId::new(tenant),
6971
None,
72+
VersionedReadSet::default(),
7073
)
7174
.expect("valid TxClass")
7275
}

nodedb-cluster/src/calvin/sequencer/entry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ mod tests {
8989
vec![0xAB],
9090
TenantId::new(1),
9191
None,
92+
crate::calvin::types::VersionedReadSet::default(),
9293
)
9394
.expect("valid TxClass");
9495

nodedb-cluster/src/calvin/sequencer/inbox.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ mod tests {
395395
vec![],
396396
TenantId::new(tenant),
397397
None,
398+
crate::calvin::types::VersionedReadSet::default(),
398399
)
399400
.expect("valid TxClass")
400401
}

nodedb-cluster/src/calvin/sequencer/service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ mod tests {
305305
vec![surr_a as u8],
306306
TenantId::new(1),
307307
None,
308+
crate::calvin::types::VersionedReadSet::default(),
308309
)
309310
.expect("valid TxClass")
310311
}

nodedb-cluster/src/calvin/sequencer/state_machine.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ mod tests {
365365
vec![],
366366
TenantId::new(1),
367367
None,
368+
crate::calvin::types::VersionedReadSet::default(),
368369
)
369370
.expect("valid TxClass");
370371
(tx_class, real_va, real_vb)

0 commit comments

Comments
 (0)