reduce anti-entropy interval for fullcopy tables
All checks were successful
ci/woodpecker/push/debug Pipeline was successful
ci/woodpecker/pr/debug Pipeline was successful

This commit is contained in:
Alex 2025-03-25 13:11:11 +01:00
parent 9dcc5232a6
commit 8ba6454e21
4 changed files with 16 additions and 4 deletions

View file

@ -1,4 +1,5 @@
use std::sync::Arc;
use std::time::Duration;
use garage_rpc::layout::*;
use garage_rpc::system::System;
@ -26,6 +27,12 @@ pub struct TableFullReplication {
impl TableReplication for TableFullReplication {
type WriteSets = Vec<Vec<Uuid>>;
// Do anti-entropy every 10 seconds.
// Compared to sharded tables, anti-entropy is much less costly as there is
// a single partition hash to exchange.
// Also, it's generally a much bigger problem for fullcopy tables to be out of sync.
const ANTI_ENTROPY_INTERVAL: Duration = Duration::from_secs(10);
fn storage_nodes(&self, _hash: &Hash) -> Vec<Uuid> {
self.system.cluster_layout().all_nodes().to_vec()
}

View file

@ -1,3 +1,5 @@
use std::time::Duration;
use garage_rpc::layout::*;
use garage_util::data::*;
@ -5,6 +7,8 @@ use garage_util::data::*;
pub trait TableReplication: Send + Sync + 'static {
type WriteSets: AsRef<Vec<Vec<Uuid>>> + AsMut<Vec<Vec<Uuid>>> + Send + Sync + 'static;
const ANTI_ENTROPY_INTERVAL: Duration;
// See examples in table_sharded.rs and table_fullcopy.rs
// To understand various replication methods

View file

@ -1,4 +1,5 @@
use std::sync::Arc;
use std::time::Duration;
use garage_rpc::layout::*;
use garage_rpc::system::System;
@ -25,6 +26,9 @@ pub struct TableShardedReplication {
}
impl TableReplication for TableShardedReplication {
// Do anti-entropy every 10 minutes
const ANTI_ENTROPY_INTERVAL: Duration = Duration::from_secs(10 * 60);
type WriteSets = WriteLock<Vec<Vec<Uuid>>>;
fn storage_nodes(&self, hash: &Hash) -> Vec<Uuid> {

View file

@ -27,9 +27,6 @@ use crate::merkle::*;
use crate::replication::*;
use crate::*;
// Do anti-entropy every 10 minutes
const ANTI_ENTROPY_INTERVAL: Duration = Duration::from_secs(10 * 60);
pub struct TableSyncer<F: TableSchema, R: TableReplication> {
system: Arc<System>,
data: Arc<TableData<F, R>>,
@ -514,7 +511,7 @@ impl<F: TableSchema, R: TableReplication> SyncWorker<F, R> {
partitions.partitions.shuffle(&mut thread_rng());
self.todo = Some(partitions);
self.next_full_sync = Instant::now() + ANTI_ENTROPY_INTERVAL;
self.next_full_sync = Instant::now() + R::ANTI_ENTROPY_INTERVAL;
}
}