Database locked error: Closes #5663
This patch resolves a potential hole when rolling back a transaction when it's been cancelled (leaving the database locked). It also fixes some minor bugs I found while investigating.
This commit is contained in:
parent
dd865890e6
commit
fe46262903
3 changed files with 7 additions and 6 deletions
|
|
@ -325,19 +325,21 @@ public class Geary.Db.Connection : Geary.Db.Context {
|
|||
throw err;
|
||||
}
|
||||
|
||||
// If transaction throws an Error, must rollback, always
|
||||
TransactionOutcome outcome = TransactionOutcome.ROLLBACK;
|
||||
Error? caught_err = null;
|
||||
try {
|
||||
// perform the transaction
|
||||
outcome = cb(this, cancellable);
|
||||
} catch (Error err) {
|
||||
debug("Connection.exec_transaction: transaction threw error %s", err.message);
|
||||
debug("Connection.exec_transaction: transaction threw error: %s", err.message);
|
||||
caught_err = err;
|
||||
}
|
||||
|
||||
// commit/rollback
|
||||
// commit/rollback ... don't use Cancellable for TransactionOutcome because it's SQL *must*
|
||||
// execute in order to unlock the database
|
||||
try {
|
||||
exec(outcome.sql(), cancellable);
|
||||
exec(outcome.sql());
|
||||
} catch (Error err) {
|
||||
debug("Connection.exec_transaction: Unable to %s transaction: %s", outcome.to_string(),
|
||||
err.message);
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ public class Geary.Db.Result : Geary.Db.Context {
|
|||
* Returns true if results are waiting, false if finished, or throws a DatabaseError.
|
||||
*/
|
||||
public bool next(Cancellable? cancellable = null) throws Error {
|
||||
check_cancelled("Result.step", cancellable);
|
||||
check_cancelled("Result.next", cancellable);
|
||||
|
||||
if (!finished) {
|
||||
finished = (throw_on_error("Result.step", statement.stmt.step())) != Sqlite.ROW;
|
||||
finished = (throw_on_error("Result.next", statement.stmt.step())) != Sqlite.ROW;
|
||||
log(finished ? "NO ROW" : "ROW");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -382,7 +382,6 @@ private class Geary.ImapDB.Account : Object {
|
|||
}
|
||||
} catch (Error err) {
|
||||
debug("Error attempting to clear duplicate folders from account: %s", err.message);
|
||||
breakpoint();
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue