Skip to content

Commit f74afc1

Browse files
committed
Don't use an arbitrary bound in histograms
I hit this trying to figure out how an mostly idle server was reporting that no connection was idle for more than 30s.
1 parent 75c51d9 commit f74afc1

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

src/conn/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,21 +1450,20 @@ mod test {
14501450

14511451
let _ = conn.query_drop("DROP USER 'test_user'@'%'").await;
14521452

1453-
let query = format!("CREATE USER 'test_user'@'%' IDENTIFIED WITH {}", plug);
1453+
let query = format!("CREATE USER 'test_user'@'%' IDENTIFIED WITH {plug}");
14541454
conn.query_drop(query).await.unwrap();
14551455

14561456
if conn.inner.version < (8, 0, 11) {
1457-
conn.query_drop(format!("SET old_passwords = {}", val))
1457+
conn.query_drop(format!("SET old_passwords = {val}"))
14581458
.await
14591459
.unwrap();
14601460
conn.query_drop(format!(
1461-
"SET PASSWORD FOR 'test_user'@'%' = PASSWORD('{}')",
1462-
pass
1461+
"SET PASSWORD FOR 'test_user'@'%' = PASSWORD('{pass}')"
14631462
))
14641463
.await
14651464
.unwrap();
14661465
} else {
1467-
conn.query_drop(format!("SET PASSWORD FOR 'test_user'@'%' = '{}'", pass))
1466+
conn.query_drop(format!("SET PASSWORD FOR 'test_user'@'%' = '{pass}'"))
14681467
.await
14691468
.unwrap();
14701469
};
@@ -1481,11 +1480,11 @@ mod test {
14811480
}
14821481

14831482
if crate::test_misc::test_compression() {
1484-
assert!(format!("{:?}", conn).contains("Compression"));
1483+
assert!(format!("{conn:?}").contains("Compression"));
14851484
}
14861485

14871486
if crate::test_misc::test_ssl() {
1488-
assert!(format!("{:?}", conn).contains("Tls"));
1487+
assert!(format!("{conn:?}").contains("Tls"));
14891488
}
14901489

14911490
conn.disconnect().await?;
@@ -1781,9 +1780,8 @@ mod test {
17811780
let mut conn = Conn::new(get_opts()).await?;
17821781
for x in (MAX_PAYLOAD_LEN - 2)..=(MAX_PAYLOAD_LEN + 2) {
17831782
let long_string = "A".repeat(x);
1784-
let result: Vec<(String, u8)> = conn
1785-
.query(format!(r"SELECT '{}', 231", long_string))
1786-
.await?;
1783+
let result: Vec<(String, u8)> =
1784+
conn.query(format!(r"SELECT '{long_string}', 231")).await?;
17871785
assert_eq!((long_string, 231_u8), result[0]);
17881786
}
17891787
conn.disconnect().await?;
@@ -2318,7 +2316,7 @@ mod test {
23182316
.tcp_port(listen_addr.port());
23192317
let server_err = match Conn::new(opts).await {
23202318
Err(Error::Server(server_err)) => server_err,
2321-
other => panic!("expected server error but got: {:?}", other),
2319+
other => panic!("expected server error but got: {other:?}"),
23222320
};
23232321
assert_eq!(
23242322
server_err,

src/conn/pool/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl MetricsHistogram {
6868
#[cfg(feature = "hdrhistogram")]
6969
impl Default for MetricsHistogram {
7070
fn default() -> Self {
71-
let hdr = hdrhistogram::Histogram::new_with_bounds(1, 30 * 1_000_000, 2).unwrap();
71+
let hdr = hdrhistogram::Histogram::new(2).unwrap();
7272
Self(std::sync::Mutex::new(hdr))
7373
}
7474
}

src/conn/pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ mod test {
627627

628628
// now we'll kill connections..
629629
for id in ids {
630-
master.query_drop(format!("KILL {}", id)).await?;
630+
master.query_drop(format!("KILL {id}")).await?;
631631
}
632632

633633
// now check, that they're still in the pool..

src/queryable/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a> Transaction<'a> {
154154
}
155155

156156
if let Some(isolation_level) = isolation_level {
157-
let query = format!("SET TRANSACTION ISOLATION LEVEL {}", isolation_level);
157+
let query = format!("SET TRANSACTION ISOLATION LEVEL {isolation_level}");
158158
conn.as_mut().query_drop(query).await?;
159159
}
160160

0 commit comments

Comments
 (0)