Skip to content

Commit

Permalink
fix namespace reset on imcompatible log
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Nov 13, 2023
1 parent 912ac4e commit b9b47ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libsql-replication/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<C: ReplicatorClient> Replicator<C> {
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;
Expand Down
9 changes: 8 additions & 1 deletion libsql-server/src/namespace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,14 @@ impl Namespace<ReplicaDatabase> {
.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();
Expand Down

0 comments on commit b9b47ee

Please sign in to comment.