From b9b47ee16cf24fa89c68274d4f7af03da55b916f Mon Sep 17 00:00:00 2001 From: ad hoc Date: Mon, 13 Nov 2023 10:47:56 +0100 Subject: [PATCH] fix namespace reset on imcompatible log --- libsql-replication/src/replicator.rs | 2 +- libsql-server/src/namespace/mod.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libsql-replication/src/replicator.rs b/libsql-replication/src/replicator.rs index d3b9b982ff..a9fcab3a18 100644 --- a/libsql-replication/src/replicator.rs +++ b/libsql-replication/src/replicator.rs @@ -157,7 +157,7 @@ impl Replicator { self.has_handshake = true; return Ok(()); } - Err(e @ Error::Fatal(_)) => return Err(e), + Err(e @ (Error::Fatal(_) | Error::Meta(_))) => return Err(e), Err(e) if !error_printed => { tracing::error!("error connecting to primary. retrying. error: {e}"); error_printed = true; diff --git a/libsql-server/src/namespace/mod.rs b/libsql-server/src/namespace/mod.rs index 4689324673..70eb5b5091 100644 --- a/libsql-server/src/namespace/mod.rs +++ b/libsql-server/src/namespace/mod.rs @@ -575,7 +575,14 @@ impl Namespace { .await?; // force a handshake now, to retrieve the primary's current replication index - replicator.try_perform_handshake().await?; + match replicator.try_perform_handshake().await { + Err(libsql_replication::replicator::Error::Meta(libsql_replication::meta::Error::LogIncompatible)) => { + tracing::error!("trying to replicate incompatible logs, reseting replica"); + (reset)(ResetOp::Reset(name.clone())); + } + Err(e) => Err(e)?, + Ok(_) => (), + } let primary_current_replicatio_index = replicator.client_mut().primary_replication_index; let mut join_set = JoinSet::new();