From 17119670c0f42224343f7853963c1596fe294fd6 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 23 Jul 2025 04:09:25 +0000 Subject: [PATCH] Add admin debug command to manually resync with primary. (#35) Signed-off-by: Jason Volk --- src/admin/debug/commands.rs | 13 +++++++++++++ src/admin/debug/mod.rs | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/admin/debug/commands.rs b/src/admin/debug/commands.rs index 10bd0a26..6c9c3e05 100644 --- a/src/admin/debug/commands.rs +++ b/src/admin/debug/commands.rs @@ -1035,3 +1035,16 @@ pub(super) async fn create_jwt( .map(async |token| self.write_str(&token).await)? .await } + +#[admin_command] +pub(super) async fn resync_database(&self) -> Result { + if !self.services.db.is_secondary() { + return Err!("Not a secondary instance."); + } + + self.services + .db + .db + .update() + .map_err(|e| err!("Failed to update from primary: {e:?}")) +} diff --git a/src/admin/debug/mod.rs b/src/admin/debug/mod.rs index c634abb7..532a7e63 100644 --- a/src/admin/debug/mod.rs +++ b/src/admin/debug/mod.rs @@ -256,6 +256,9 @@ pub(super) enum DebugCommand { audience: Option, }, + /// - Synchronize database with primary (secondary only) + ResyncDatabase, + /// - Developer test stubs #[command(subcommand)] #[allow(non_snake_case)]