From f22d5d3e513fd40c180cde6fc773a8ef7a441826 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 29 Aug 2022 12:29:38 +0100 Subject: [PATCH] Ensure read-only transactions are cancelled when complete --- lib/src/dbs/executor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/dbs/executor.rs b/lib/src/dbs/executor.rs index dbca50ea..bb0afbc5 100644 --- a/lib/src/dbs/executor.rs +++ b/lib/src/dbs/executor.rs @@ -255,7 +255,10 @@ impl<'a> Executor<'a> { }; // Finalise transaction match &res { - Ok(_) => self.commit(loc).await, + Ok(_) => match stm.writeable() { + true => self.commit(loc).await, + false => self.cancel(loc).await, + }, Err(_) => self.cancel(loc).await, }; // Return the result