DSS: There is something strange about the tests in kvraft (lab3).
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. What did you do?
In client.rs, we will see
pub fn get(&self, key: String) -> String { /* snip */ }
pub fn put(&self, key: String, value: String) { /* snip */ }
pub fn append(&self, key: String, value: String) { /* snip */ }These public methods are not async, but they have to call some async RPCs. I try to solve this with futures::executor::block_on, now the methods will block until success even if the servers are down.
2. What did you expect to see?
Pass all the tests in kvraft.
3. What did you see instead?
In test_one_partition_3a:
cfg.net.spawn(future::lazy(move |_| {
ckp2a.put("1".to_owned(), "15".to_owned());
// snip
}));
// snip
cfg.net.spawn(future::lazy(move |_| {
// different clerk in p2
ckp2b.get("1".to_owned());
// snip
}));Run executor::block_on (LocalPool) from within cfg.net.spawn (ThreadPool) will panic with EnterError. Maybe we can solve this with something else, but the limitation is too inconvenient.
In generic_test_linearizability:
let operations = Arc::new(Mutex::new(vec![]));
// Clone the `operations`, move to `async` block, and call the methods.
// Shut down the servers and tell the clients to quit.
if !check_operations_timeout(
KvModel {},
Arc::try_unwrap(operations).unwrap().into_inner().unwrap(),
LINEARIZABILITY_CHECK_TIMEOUT,
) {
panic!("history is not linearizable");
}Since the methods must succeed, they have to retry calling RPCs. So we cannot tell the clients to quit via shutting down the servers, and the Arc::try_unwrap may return Err and lead to panic.
Source: pingcap/talent-plan