diff --git a/src/audit.rs b/src/audit.rs index b63eb6f79a94be700685a4aaceb5fe9d5cef7d5d..9b8952af790b043e7f8af7e985c0ef02d77f20bd 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 caaa41f3271527fde66758623e1424a0bc13b09f..e331d5bb1d016358ebcd9503ee8f196d024afa0c 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 {