Bugfix - ret. QueryNotExecuted if implicit txn. fails to commit. ()

This commit is contained in:
Finn Bear 2023-05-23 15:03:59 -07:00 committed by GitHub
parent e962eae70c
commit 5e0e72def2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions
lib/src

View file

@ -296,14 +296,22 @@ impl<'a> Executor<'a> {
// There is no timeout clause
None => stm.compute(&ctx, &opt, &self.txn(), None).await,
};
// Finalise transaction
// Finalise transaction and return the result.
if res.is_ok() && stm.writeable() {
self.commit(loc).await;
if self.err {
// The commit failed
Err(Error::QueryNotExecuted)
} else {
// Successful, committed result
res
}
} else {
self.cancel(loc).await;
// An error
res
}
// Return the result
res
}
}
}

View file

@ -86,7 +86,7 @@ impl Transaction {
}
// Mark this transaction as done
self.ok = true;
// Cancel this transaction
// Commit this transaction
self.tx.commit().await?;
// Continue
Ok(())