From c454efcff34ad532b324632c80a81fae3801e1a1 Mon Sep 17 00:00:00 2001 From: Lucian Buzzo Date: Thu, 9 Jan 2025 13:43:16 +0000 Subject: [PATCH] fix: reset the tx depth to 0 on commit --- quaint/src/connector/transaction.rs | 3 ++- query-engine/driver-adapters/src/transaction.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quaint/src/connector/transaction.rs b/quaint/src/connector/transaction.rs index 2517533bc45..a861748b2b5 100644 --- a/quaint/src/connector/transaction.rs +++ b/quaint/src/connector/transaction.rs @@ -144,7 +144,8 @@ impl Transaction for DefaultTransaction<'_> { async fn commit(&self) -> crate::Result<()> { self.inner.raw_cmd("COMMIT").await?; - self.depth.fetch_sub(1, Ordering::Relaxed); + // Reset the depth to 0 on commit + self.depth.store(0, Ordering::Relaxed); self.gauge.decrement(); diff --git a/query-engine/driver-adapters/src/transaction.rs b/query-engine/driver-adapters/src/transaction.rs index 67549e1fa5e..8f80feb9b6c 100644 --- a/query-engine/driver-adapters/src/transaction.rs +++ b/query-engine/driver-adapters/src/transaction.rs @@ -161,8 +161,8 @@ impl QuaintTransaction for JsTransaction { let _ = UnsafeFuture(self.tx_proxy.commit()).await; - // Modify the depth value - self.depth.fetch_sub(1, Ordering::Relaxed); + // Reset the depth to 0 on commit + self.depth.store(0, Ordering::Relaxed); Ok(()) }