use a WriteLock for write operations on fullcopy tables
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
ci/woodpecker/push/debug Pipeline was successful

This commit is contained in:
Alex 2025-03-25 13:18:14 +01:00
parent 8ba6454e21
commit 2c87d9fca5
3 changed files with 13 additions and 11 deletions

View file

@ -143,13 +143,16 @@ impl LayoutManager {
// ---- ACK LOCKING ----
pub fn write_sets_of(self: &Arc<Self>, hash: &Hash) -> WriteLock<Vec<Vec<Uuid>>> {
pub fn write_sets_of(self: &Arc<Self>, hash: Option<&Hash>) -> WriteLock<Vec<Vec<Uuid>>> {
let layout = self.layout();
let version = layout.current().version;
let nodes = layout
.versions()
.iter()
.map(|x| x.nodes_of(hash).collect())
.map(|x| match hash {
Some(h) => x.nodes_of(h).collect(),
None => x.all_nodes().to_vec(),
})
.collect();
layout
.ack_lock

View file

@ -25,7 +25,7 @@ pub struct TableFullReplication {
}
impl TableReplication for TableFullReplication {
type WriteSets = Vec<Vec<Uuid>>;
type WriteSets = WriteLock<Vec<Vec<Uuid>>>;
// Do anti-entropy every 10 seconds.
// Compared to sharded tables, anti-entropy is much less costly as there is
@ -51,12 +51,7 @@ impl TableReplication for TableFullReplication {
}
fn write_sets(&self, _hash: &Hash) -> Self::WriteSets {
self.system
.cluster_layout()
.versions()
.iter()
.map(|ver| ver.all_nodes().to_vec())
.collect()
self.system.layout_manager.write_sets_of(None)
}
fn write_quorum(&self) -> usize {
let layout = self.system.cluster_layout();
@ -92,7 +87,11 @@ impl TableReplication for TableFullReplication {
partition: 0u16,
first_hash: [0u8; 32].into(),
last_hash: [0xff; 32].into(),
storage_sets: self.write_sets(&[0u8; 32].into()),
storage_sets: layout
.versions()
.iter()
.map(|ver| ver.all_nodes().to_vec())
.collect(),
}];
SyncPartitions {

View file

@ -54,7 +54,7 @@ impl TableReplication for TableShardedReplication {
}
fn write_sets(&self, hash: &Hash) -> Self::WriteSets {
self.system.layout_manager.write_sets_of(hash)
self.system.layout_manager.write_sets_of(Some(hash))
}
fn write_quorum(&self) -> usize {
self.write_quorum