diff --git a/openraft/src/core/raft_core.rs b/openraft/src/core/raft_core.rs index 7638a40b9..007b4dd0d 100644 --- a/openraft/src/core/raft_core.rs +++ b/openraft/src/core/raft_core.rs @@ -710,7 +710,7 @@ where { tracing::debug!("append_to_log"); - let (tx, rx) = C::AsyncRuntime::oneshot(); + let (tx, rx) = C::oneshot(); let log_io_id = LogIOId::new(vote, Some(last_log_id)); let callback = LogFlushed::new(log_io_id, tx); @@ -1622,7 +1622,7 @@ where self.log_store.purge(upto).await?; self.engine.state.io_state_mut().update_purged(Some(upto)); } - Command::DeleteConflictLog { since } => { + Command::TruncateLog { since } => { self.log_store.truncate(since).await?; // Inform clients waiting for logs to be applied. diff --git a/openraft/src/engine/command.rs b/openraft/src/engine/command.rs index 8b0db363f..58a19e9d9 100644 --- a/openraft/src/engine/command.rs +++ b/openraft/src/engine/command.rs @@ -92,7 +92,7 @@ where C: RaftTypeConfig /// Delete logs that conflict with the leader from a follower/learner since log id `since`, /// inclusive. - DeleteConflictLog { since: LogId }, + TruncateLog { since: LogId }, // TODO(1): current it is only used to replace BuildSnapshot, InstallSnapshot, CancelSnapshot. /// A command send to state machine worker [`sm::worker::Worker`]. @@ -135,7 +135,7 @@ where (Command::SaveVote { vote }, Command::SaveVote { vote: b }) => vote == b, (Command::SendVote { vote_req }, Command::SendVote { vote_req: b }, ) => vote_req == b, (Command::PurgeLog { upto }, Command::PurgeLog { upto: b }) => upto == b, - (Command::DeleteConflictLog { since }, Command::DeleteConflictLog { since: b }, ) => since == b, + (Command::TruncateLog { since }, Command::TruncateLog { since: b }, ) => since == b, (Command::Respond { when, resp: send }, Command::Respond { when: b_when, resp: b }) => send == b && when == b_when, (Command::StateMachine { command }, Command::StateMachine { command: b }) => command == b, _ => false, @@ -158,7 +158,7 @@ where C: RaftTypeConfig Command::AppendInputEntries { .. } => CommandKind::Log, Command::SaveVote { .. } => CommandKind::Log, Command::PurgeLog { .. } => CommandKind::Log, - Command::DeleteConflictLog { .. } => CommandKind::Log, + Command::TruncateLog { .. } => CommandKind::Log, Command::ReplicateCommitted { .. } => CommandKind::Network, Command::Replicate { .. } => CommandKind::Network, @@ -187,7 +187,7 @@ where C: RaftTypeConfig Command::SaveVote { .. } => None, Command::SendVote { .. } => None, Command::PurgeLog { .. } => None, - Command::DeleteConflictLog { .. } => None, + Command::TruncateLog { .. } => None, Command::Respond { when, .. } => when.as_ref(), // TODO(1): Command::StateMachine { .. } => None, diff --git a/openraft/src/engine/engine_output.rs b/openraft/src/engine/engine_output.rs index 824b6ebed..dc89d19a3 100644 --- a/openraft/src/engine/engine_output.rs +++ b/openraft/src/engine/engine_output.rs @@ -57,7 +57,7 @@ where C: RaftTypeConfig Command::SaveVote { .. } => {} Command::SendVote { .. } => {} Command::PurgeLog { .. } => {} - Command::DeleteConflictLog { .. } => {} + Command::TruncateLog { .. } => {} Command::Respond { .. } => {} } self.commands.push_back(cmd) diff --git a/openraft/src/engine/handler/following_handler/install_snapshot_test.rs b/openraft/src/engine/handler/following_handler/install_snapshot_test.rs index 9409497fc..87767ccfe 100644 --- a/openraft/src/engine/handler/following_handler/install_snapshot_test.rs +++ b/openraft/src/engine/handler/following_handler/install_snapshot_test.rs @@ -222,7 +222,7 @@ fn test_install_snapshot_conflict() -> anyhow::Result<()> { assert_eq!( vec![ // - Command::DeleteConflictLog { since: log_id(2, 1, 4) }, + Command::TruncateLog { since: log_id(2, 1, 4) }, Command::from( sm::Command::install_full_snapshot(Snapshot { meta: SnapshotMeta { diff --git a/openraft/src/engine/handler/following_handler/mod.rs b/openraft/src/engine/handler/following_handler/mod.rs index a618fe95d..f7de78fbe 100644 --- a/openraft/src/engine/handler/following_handler/mod.rs +++ b/openraft/src/engine/handler/following_handler/mod.rs @@ -197,7 +197,7 @@ where C: RaftTypeConfig }; self.state.log_ids.truncate(since); - self.output.push_command(Command::DeleteConflictLog { since: since_log_id }); + self.output.push_command(Command::TruncateLog { since: since_log_id }); let changed = self.state.membership_state.truncate(since); if let Some(_c) = changed { diff --git a/openraft/src/engine/handler/following_handler/truncate_logs_test.rs b/openraft/src/engine/handler/following_handler/truncate_logs_test.rs index 2b280e9a9..56b2415bf 100644 --- a/openraft/src/engine/handler/following_handler/truncate_logs_test.rs +++ b/openraft/src/engine/handler/following_handler/truncate_logs_test.rs @@ -65,7 +65,7 @@ fn test_truncate_logs_since_3() -> anyhow::Result<()> { assert_eq!( vec![ // - Command::DeleteConflictLog { since: log_id(2, 1, 3) }, + Command::TruncateLog { since: log_id(2, 1, 3) }, ], eng.output.take_commands() ); @@ -91,7 +91,7 @@ fn test_truncate_logs_since_4() -> anyhow::Result<()> { assert_eq!(ServerState::Follower, eng.state.server_state); assert_eq!( - vec![Command::DeleteConflictLog { since: log_id(4, 1, 4) }], + vec![Command::TruncateLog { since: log_id(4, 1, 4) }], eng.output.take_commands() ); @@ -107,7 +107,7 @@ fn test_truncate_logs_since_5() -> anyhow::Result<()> { assert_eq!(Some(&log_id(4, 1, 4)), eng.state.last_log_id()); assert_eq!(&[log_id(2, 1, 2), log_id(4, 1, 4)], eng.state.log_ids.key_log_ids()); assert_eq!( - vec![Command::DeleteConflictLog { since: log_id(4, 1, 5) }], + vec![Command::TruncateLog { since: log_id(4, 1, 5) }], eng.output.take_commands() ); @@ -126,7 +126,7 @@ fn test_truncate_logs_since_6() -> anyhow::Result<()> { eng.state.log_ids.key_log_ids() ); assert_eq!( - vec![Command::DeleteConflictLog { since: log_id(4, 1, 6) }], + vec![Command::TruncateLog { since: log_id(4, 1, 6) }], eng.output.take_commands() ); @@ -181,7 +181,7 @@ fn test_truncate_logs_revert_effective_membership() -> anyhow::Result<()> { assert_eq!( vec![ // - Command::DeleteConflictLog { since: log_id(4, 1, 4) }, + Command::TruncateLog { since: log_id(4, 1, 4) }, ], eng.output.take_commands() ); diff --git a/openraft/src/engine/tests/append_entries_test.rs b/openraft/src/engine/tests/append_entries_test.rs index 6ea78e672..6f0538813 100644 --- a/openraft/src/engine/tests/append_entries_test.rs +++ b/openraft/src/engine/tests/append_entries_test.rs @@ -157,7 +157,7 @@ fn test_append_entries_prev_log_id_conflict() -> anyhow::Result<()> { Command::SaveVote { vote: Vote::new_committed(2, 1) }, - Command::DeleteConflictLog { since: log_id(1, 1, 2) }, + Command::TruncateLog { since: log_id(1, 1, 2) }, ], eng.output.take_commands() ); @@ -197,7 +197,7 @@ fn test_append_entries_prev_log_id_is_committed() -> anyhow::Result<()> { Command::SaveVote { vote: Vote::new_committed(2, 1) }, - Command::DeleteConflictLog { since: log_id(1, 1, 2) }, + Command::TruncateLog { since: log_id(1, 1, 2) }, Command::AppendInputEntries { vote: Vote::new_committed(2, 1), entries: vec![blank_ent(2, 1, 2)] @@ -291,7 +291,7 @@ fn test_append_entries_conflict() -> anyhow::Result<()> { Command::SaveVote { vote: Vote::new_committed(2, 1) }, - Command::DeleteConflictLog { since: log_id(2, 1, 3) }, + Command::TruncateLog { since: log_id(2, 1, 3) }, Command::AppendInputEntries { vote: Vote::new_committed(2, 1), entries: vec![Entry::new_membership(log_id(3, 1, 3), m34())]