diff --git a/.zetch.lock b/.zetch.lock index beaef43a..1a2c7874 100644 --- a/.zetch.lock +++ b/.zetch.lock @@ -18,6 +18,7 @@ "py_rust/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", "py_rust/README.zetch.md": "20c5d0860abd2f274e0a4e911c6bb4f01cdd4e28f6b331d85cb7cf3cd8056855", "rust/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", - "rust/README.zetch.md": "20c5d0860abd2f274e0a4e911c6bb4f01cdd4e28f6b331d85cb7cf3cd8056855" + "rust/README.zetch.md": "20c5d0860abd2f274e0a4e911c6bb4f01cdd4e28f6b331d85cb7cf3cd8056855", + "rust/pkg/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b" } } \ No newline at end of file diff --git a/rust/bitbazaar/redis/conn.rs b/rust/bitbazaar/redis/conn.rs index 8232d8e9..0239563f 100644 --- a/rust/bitbazaar/redis/conn.rs +++ b/rust/bitbazaar/redis/conn.rs @@ -4,7 +4,7 @@ use deadpool_redis::redis::{FromRedisValue, ToRedisArgs}; use once_cell::sync::Lazy; use super::batch::{RedisBatch, RedisBatchFire, RedisBatchReturningOps}; -use crate::{errors::prelude::*, redis::RedisScript}; +use crate::{errors::prelude::*, log::record_exception, redis::RedisScript}; /// Wrapper around a lazy redis connection. pub struct RedisConn<'a> { @@ -33,7 +33,7 @@ impl<'a> RedisConn<'a> { match self.pool.get().await { Ok(conn) => self.conn = Some(conn), Err(e) => { - tracing::error!("Could not get redis connection: {}", e); + record_exception("Failed to get redis connection.", format!("{:?}", e)); return None; } } diff --git a/rust/bitbazaar/redis/standalone.rs b/rust/bitbazaar/redis/standalone.rs index 6ea085ce..847d2de8 100644 --- a/rust/bitbazaar/redis/standalone.rs +++ b/rust/bitbazaar/redis/standalone.rs @@ -27,18 +27,20 @@ impl RedisStandalone { let child = cmd.spawn().change_context(AnyErr)?; // Wait for redis to come up, raising if waited for 10 seconds. + let client = Redis::new( + format!("redis://localhost:{}", port), + uuid::Uuid::new_v4().to_string(), + )?; let mut up = false; let elapsed = Instant::now(); while !up && elapsed.elapsed() < std::time::Duration::from_secs(10) { - up = Redis::new( - format!("redis://localhost:{}", port), - uuid::Uuid::new_v4().to_string(), - )? - .conn() - .ping() - .await + // Using low level check of conn first, as inner will record an exception which we don't really need during this startup check: + if client.get_inner_pool().get().await.is_ok() { + up = client.conn().ping().await + } } - if up { + // Final ping as that interface conn() will actually log an error on failure to connect: + if up || client.conn().ping().await { Ok(Self { child, port }) } else { Err(anyerr!("RedisStandalone process not ready in 10 seconds."))