Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: wrong response of fast_round if there are two leaders #583

Open
1 task done
iGxnon opened this issue Dec 20, 2023 · 1 comment
Open
1 task done

[Bug]: wrong response of fast_round if there are two leaders #583

iGxnon opened this issue Dec 20, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@iGxnon
Copy link
Contributor

iGxnon commented Dec 20, 2023

Description about the bug

In #582, the test case will failed, we should fixed it.

/// FIXME: two leader
/// TODO: fix in subsequence PR
#[traced_test]
#[tokio::test]
#[should_panic]
async fn test_unary_fast_round_with_two_leader() {
    let connects = init_mocked_connects(5, |id, conn| {
        conn.expect_propose().return_once(move |_req, _timeout| {
            let resp = match id {
                // The execution result has been returned, indicating that server(0) has also recorded the command.
                0 => ProposeResponse::new_result::<TestCommand>(&Ok(TestCommandResult::new(
                    vec![1],
                    vec![1],
                ))),
                // imagine that server(1) is the new leader
                1 => ProposeResponse::new_result::<TestCommand>(&Ok(TestCommandResult::new(
                    vec![2],
                    vec![2],
                ))),
                2 | 3 => ProposeResponse::new_empty(),
                4 => return Err(CurpError::key_conflict()),
                _ => unreachable!("there are only 3 nodes"),
            };
            Ok(tonic::Response::new(resp))
        });
    });
    // old local leader(0), term 1
    let unary = Unary::<TestCommand>::new(connects, None, Some((0, 1)));
    let res = unary
        .fast_round(ProposeId(0, 0), &TestCommand::default())
        .await
        .unwrap()
        .unwrap();
    // quorum: server(0, 1, 2, 3)
    assert_eq!(res, TestCommandResult::new(vec![2], vec![2]));
}

Version

0.6.0 (Default)

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@iGxnon iGxnon added the bug Something isn't working label Dec 20, 2023
@iGxnon
Copy link
Contributor Author

iGxnon commented Dec 20, 2023

By introducing leader_id and term in ProposeRequest, we may fix that bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant