Skip to content

Commit 50964d0

Browse files
committed
refactor: adjust logs
1 parent b390356 commit 50964d0

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

async-raft/src/core/client.rs

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
7373
entry: Arc::new(entry),
7474
tx: None,
7575
};
76+
// TODO(xp): it should update the lost_log_id
7677
self.replicate_client_request(cr_entry).await;
7778

7879
Ok(())

async-raft/src/core/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
714714
self.core.update_current_leader(UpdateCurrentLeader::ThisNode);
715715
self.leader_report_metrics();
716716

717-
// Per §8, commit an initial entry as part of becoming the cluster leader.
718717
self.commit_initial_leader_entry().await?;
719718

720719
loop {

async-raft/src/replication/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct ReplicationCore<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: Raf
139139

140140
impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> ReplicationCore<D, R, N, S> {
141141
/// Spawn a new replication task for the target node.
142+
#[tracing::instrument(level = "debug", skip(config, network, storage, raft_core_tx))]
142143
pub(self) fn spawn(
143144
id: NodeId,
144145
target: NodeId,
@@ -383,6 +384,7 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Re
383384
}
384385

385386
/// max_possible_matched_index is the least index for `prev_log_id` to form a consecutive log sequence
387+
#[tracing::instrument(level = "debug", skip(self), fields(max_possible_matched_index=self.max_possible_matched_index))]
386388
fn check_consecutive(&self, first_log_index: u64) -> Result<(), ReplicationError> {
387389
if first_log_index > self.max_possible_matched_index {
388390
return Err(ReplicationError::LackEntry(LackEntry {

async-raft/tests/append_conflicts.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,13 @@ where
209209
Sto: RaftStorage<D, R>,
210210
{
211211
let logs = sto.get_log_entries(..).await?;
212-
let want: Vec<Entry<ClientRequest>> =
213-
terms.iter().enumerate().map(|(i, term)| ent(*term, (i) as u64)).collect::<Vec<_>>();
212+
let skip = 0;
213+
let want: Vec<Entry<ClientRequest>> = terms
214+
.iter()
215+
.skip(skip)
216+
.enumerate()
217+
.map(|(i, term)| ent(*term, (i + skip) as u64))
218+
.collect::<Vec<_>>();
214219

215220
assert_eq!(want.as_slice().summary(), logs.as_slice().summary());
216221

async-raft/tests/members.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ async fn members_add_absent_non_voter_blocking() -> Result<()> {
115115
for node_id in 0..2 {
116116
let sto = router.get_storage_handle(&node_id).await?;
117117
let logs = sto.get_log_entries(..).await?;
118-
assert_eq!(n_logs, logs[logs.len() - 1].log_id.index);
118+
assert_eq!(n_logs, logs[logs.len() - 1].log_id.index, "node: {}", node_id);
119119
// 0-th log
120-
assert_eq!(n_logs + 1, logs.len() as u64);
120+
assert_eq!(n_logs + 1, logs.len() as u64, "node: {}", node_id);
121121
}
122122
}
123123

0 commit comments

Comments
 (0)