From 64bf75117bd8838e684d5c498721f96e5ec7ac8c Mon Sep 17 00:00:00 2001
From: Gareth Andrew Lloyd <gareth.lloyd@memgraph.io>
Date: Mon, 16 Oct 2023 21:56:56 +0100
Subject: [PATCH] Fix subtle replication bug (#1370)

When going from REPLICA to MAIN, need to ensure current WAL files are
finalised.
---
 src/storage/v2/replication/replication_handler.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storage/v2/replication/replication_handler.cpp b/src/storage/v2/replication/replication_handler.cpp
index 4ba1edf69..137a15713 100644
--- a/src/storage/v2/replication/replication_handler.cpp
+++ b/src/storage/v2/replication/replication_handler.cpp
@@ -47,7 +47,7 @@ bool ReplicationHandler::SetReplicationRoleMain() {
     // ensure replica server brought down
     storage_.repl_storage_state_.replication_server_.reset(nullptr);
     // Remember old epoch + storage timestamp association
-    storage_.repl_storage_state_.AddEpochToHistory(current_epoch);
+    storage_.PrepareForNewEpoch(current_epoch);
   }
 
   // STEP 2) Change to MAIN