Skip to content

Commit

Permalink
Merge pull request #1947 from Expensify/tyler-fix-warning-message
Browse files Browse the repository at this point in the history
Fix log message
  • Loading branch information
grgia authored Nov 11, 2024
2 parents d88ea07 + c76f524 commit 0de2ad3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions sqlitecluster/SQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,22 @@ bool SQLite::beginTransaction(TRANSACTION_TYPE type) {
_mutexLocked = true;
}

if (_insideTransaction || !_uncommittedHash.empty() || !_uncommittedQuery.empty()) {
// The most likely case for hitting this is that we forgot to roll back a transaction when we were finished with it
// during the last use of this DB handle. In that case, `_insideTransaction` is likely true, and possibly
// _uncommittedHash or _uncommittedQuery is set. Rollback should put this DB handle back into a usable state,
// but it breaks the current transaction on this handle. We throw and fail the one transaction and hopefully have
// fixed the handle for the next use.
// The most likely case for hitting this is that we forgot to roll back a transaction when we were finished with it
// during the last use of this DB handle. In that case, `_insideTransaction` is likely true, and possibly
// _uncommittedHash or _uncommittedQuery is set. Rollback should put this DB handle back into a usable state,
// but it breaks the current transaction on this handle. We throw and fail the one transaction and hopefully have
// fixed the handle for the next use
if (_insideTransaction) {
rollback();
STHROW("Attempted to begin transaction while in invalid state: already inside transaction");
}
if (!_uncommittedHash.empty()) {
rollback();
STHROW("Attempted to begin transaction while in invalid state: _uncommittedHash not empty");
}
if (!_uncommittedQuery.empty()) {
rollback();
STHROW("Attempted to begin transaction while in invalid state. _insideTransaction="s +
(_insideTransaction ? "true" : "false") + ", _uncommittedHash='" + _uncommittedHash +
", _uncommittedQuery empty? " + (_uncommittedQuery.empty() ? "true" : "false"));
STHROW("Attempted to begin transaction while in invalid state: _uncommittedQuery not empty");
}

// Reset before the query, as it's possible the query sets these.
Expand Down

0 comments on commit 0de2ad3

Please sign in to comment.