mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-11 14:56:53 +00:00
use a WriteLock for write operations on fullcopy tables
This commit is contained in:
@@ -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
|
||||
@@ -52,11 +52,8 @@ 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()
|
||||
.layout_manager
|
||||
.write_lock_with(|l| l.write_sets_of(None))
|
||||
}
|
||||
fn write_quorum(&self) -> usize {
|
||||
let layout = self.system.cluster_layout();
|
||||
@@ -92,7 +89,7 @@ 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.write_sets_of(None),
|
||||
}];
|
||||
|
||||
SyncPartitions {
|
||||
|
||||
@@ -54,7 +54,9 @@ 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_lock_with(|l| l.write_sets_of(Some(hash)))
|
||||
}
|
||||
fn write_quorum(&self) -> usize {
|
||||
self.write_quorum
|
||||
@@ -72,16 +74,11 @@ impl TableReplication for TableShardedReplication {
|
||||
.current()
|
||||
.partitions()
|
||||
.map(|(partition, first_hash)| {
|
||||
let storage_sets = layout
|
||||
.versions()
|
||||
.iter()
|
||||
.map(|x| x.nodes_of(&first_hash).collect())
|
||||
.collect();
|
||||
SyncPartition {
|
||||
partition,
|
||||
first_hash,
|
||||
last_hash: [0u8; 32].into(), // filled in just after
|
||||
storage_sets,
|
||||
storage_sets: layout.write_sets_of(Some(&first_hash)),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Reference in New Issue
Block a user