Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_coalescing: improve error handling
`test_coalescing` spawns a lot of tokio tasks, each of which runs a query on the database. If a query fails, the task will panic because of the `unwrap()`. The problem is that all of the tasks are joined using `join_all`, which doesn't check for errors in the joined tasks. For example, this piece of code prints "Ok!" and the program finishes successfuly: ```rust let mut tasks = Vec::new(); for _i in 0..4 { tasks.push(tokio::spawn(async { panic!("Panic!") })); } futures::future::join_all(tasks).await; println!("Ok!"); ``` There are some error messages in the output, but the important thig is that they don't stop the control flow. To fix it, let's use `try_join_all` instead of `join_all`. `try_join_all` will check whether the task panicked or not, and return an error if there was a panic. I manually tested that it works by inserting a panic!() after `conn.query()`. Let's also make sure that the result of join_all doesn't contain any `Result<>`, as it could hide the errors. The result of `join_all` should be just a `Vec<>` of unit values. Refs: scylladb#828 Signed-off-by: Jan Ciolek <[email protected]>
- Loading branch information