You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attaching/Detaching process with strace during a running query might cause a CodecError due to
interrupted systemcall.
Subsequent queries will then return a "Packets out of sync" CodecError
read_timeout needs to be enabled to reproduce the issue (i was not able to reproduce it without it).
Term 1:
$ cargo run --release
Compiling rust-mysql-outofsync v0.1.0 (/home/endy/rust-mysql-outofsync)
Finished dev [unoptimized + debuginfo] target(s) in 2.13s
Running `target/debug/rust-mysql-outofsync`
PID to strace: 10503Running query that will be interrupted by a strace on the application PID
CodecError { IO error: `Interrupted system call (os error 4)' }
Then running another query
error occured: mysql error: "CodecError { Packets out of sync }"
Term 2:
$ sudo strace -f-p 10503
The program itself:
use mysql::prelude::Queryable;use std::time::Duration;use err_derive::Error;#[derive(Debug,Error)]pubenumMyError{#[error(display = "mysql error: {:?}", _0)]MySQLError(String),}constUSER:&str = "my_user";constPASS:&str = "my_pass";constHOST:&str = "my_host";constDB:&str = "my_db";constTABLE:&str = "my_table";fnbug_if_straced(conn:&mut mysql::Conn) -> Result<(),MyError>{// my_table contains a few millions entries in order// to have time to attach strace to the running process while// fetching rowslet query = format!("SELECT * FROM {}.{}", DB, TABLE);let statement = conn.exec_iter(query,());let iter = statement
.map_err(|e| MyError::MySQLError(format!("{}", e)))?;for i in iter {ifletErr(e) = i {println!("{:?}", e);break;}}Ok(())}fnrun_bug_if_straced(conn:&mut mysql::Conn){ifletErr(e) = bug_if_straced(conn){println!("error occured: {}", e);}}fnmain(){println!("PID to strace: {}", std::process::id());// Note: i can only reproduce the issue when read_timeout is specifiedlet conn_builder = mysql::OptsBuilder::new().user(Some(USER)).pass(Some(PASS)).ip_or_hostname(Some(HOST)).read_timeout(Some(Duration::from_millis(60000)));letmut conn = mysql::Conn::new(conn_builder).unwrap();println!("Running query that will be interrupted by a strace on the application PID");run_bug_if_straced(&mut conn);println!("Then running another query");run_bug_if_straced(&mut conn);}
The Cargo.toml file:
[package]
name = "rust-mysql-outofsync"version = "0.1.0"edition = "2018"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
mysql = { version = "18.2.0", features = [] }
err-derive = "0.2"
The issue does not happen 100% of the time but is easy to reproduce while compiled in release mode.
It happens either right after attaching process with strace, or right after detaching.
The text was updated successfully, but these errors were encountered:
Attaching/Detaching process with strace during a running query might cause a CodecError due to
interrupted systemcall.
Subsequent queries will then return a "Packets out of sync" CodecError
read_timeout
needs to be enabled to reproduce the issue (i was not able to reproduce it without it).Term 1:
Term 2:
The program itself:
The Cargo.toml file:
The issue does not happen 100% of the time but is easy to reproduce while compiled in release mode.
It happens either right after attaching process with strace, or right after detaching.
The text was updated successfully, but these errors were encountered: