From 195ac0239170c9e3ddd93b28971045f35849def6 Mon Sep 17 00:00:00 2001 From: Egor Ivkov <e.o.ivkov@gmail.com> Date: Mon, 1 Apr 2024 17:36:44 +0300 Subject: [PATCH] refactor: have separate params for raft_id and raft_gen in audit::init (cherry picked from commit 466cecc5215ecd0dc814f8cc0a99d24fd05f745d) --- src/audit.rs | 11 ++--------- src/lib.rs | 7 ++++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/audit.rs b/src/audit.rs index b63eb6f79a..9b8952af79 100644 --- a/src/audit.rs +++ b/src/audit.rs @@ -386,20 +386,13 @@ macro_rules! audit( /// Initialize audit log. /// Unique id generation depends on the raft machine's state. /// Note: `config` will be parsed by tarantool's core (see `say.c`). -pub fn init(config: &str, raft_storage: &RaftSpaceAccess) { - // Raft-related stuff should be ready at this point. - let raft_id = raft_storage - .raft_id() - .expect("failed to get raft_id for audit log") - .expect("found zero raft_id during audit log init"); - let gen = raft_storage.gen().expect("failed to get gen for audit log"); - +pub fn init(config: &str, raft_id: u64, raft_gen: u64) { // Note: this'll only fail if the cell's already set (shouldn't be possible). // SAFETY: this is the first time we access this variable, and it's // always done from the main (TX) thread. unsafe { CLOCK - .set(LogicalClock::new(raft_id, gen)) + .set(LogicalClock::new(raft_id, raft_gen)) .expect("failed to initialize global audit event id generator"); } diff --git a/src/lib.rs b/src/lib.rs index caaa41f327..e331d5bb1d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -811,7 +811,12 @@ fn postjoin( config.validate_storage(&storage, &raft_storage)?; if let Some(config) = &config.instance.audit { - audit::init(config, &raft_storage); + let raft_id = raft_storage + .raft_id() + .expect("failed to get raft_id for audit log") + .expect("found zero raft_id during audit log init"); + let gen = raft_storage.gen().expect("failed to get gen for audit log"); + audit::init(config, raft_id, gen); } if let Some(plugins) = &config.instance.plugins { -- GitLab