From 9473d7620a95c1e8eda7838136294ece40d0c0af Mon Sep 17 00:00:00 2001 From: John Lee Date: Wed, 11 Dec 2024 14:38:52 -0500 Subject: [PATCH] Move openTransactionCount around --- sqlitecluster/SQLite.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sqlitecluster/SQLite.cpp b/sqlitecluster/SQLite.cpp index e0ded6539..a83d91e4d 100644 --- a/sqlitecluster/SQLite.cpp +++ b/sqlitecluster/SQLite.cpp @@ -401,13 +401,13 @@ bool SQLite::beginTransaction(TRANSACTION_TYPE type) { // Reset before the query, as it's possible the query sets these. _autoRolledBack = false; - SINFO("[concurrent] Beginning transaction - open transaction count: " << (_sharedData.openTransactionCount + 1)); - uint64_t before = STimeNow(); - _insideTransaction = !SQuery(_db, "starting db transaction", "BEGIN CONCURRENT"); - // We actively track transaction counts incrementing and decrementing to log the number of active open transactions at any given moment. _sharedData.openTransactionCount++; + SINFO("[concurrent] Beginning transaction - open transaction count: " << (_sharedData.openTransactionCount)); + uint64_t before = STimeNow(); + _insideTransaction = !SQuery(_db, "starting db transaction", "BEGIN CONCURRENT"); + // Because some other thread could commit once we've run `BEGIN CONCURRENT`, this value can be slightly behind // where we're actually able to start such that we know we shouldn't get a conflict if this commits successfully on // leader. However, this is perfectly safe, it just adds the possibility that threads on followers wait for an