From dd8f98a2ab214936811ecd39b0f0bcaf3ded1ef2 Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Mon, 18 Apr 2016 16:06:27 +0930 Subject: [PATCH] Ensure we rollback if commit fails --- rhizome_store.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rhizome_store.c b/rhizome_store.c index ff31141b..158a5d4e 100644 --- a/rhizome_store.c +++ b/rhizome_store.c @@ -451,8 +451,10 @@ static int write_release_lock(struct rhizome_write *write_state) if (write_state->sql_blob){ ret = sqlite_blob_close(write_state->sql_blob); sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT; - if (sqlite_exec_void_retry(&retry, "COMMIT;", END) == -1) + if (sqlite_exec_void_retry(&retry, "COMMIT;", END) == -1){ + sqlite_exec_void_retry(&retry, "ROLLBACK;", END); ret=-1; + } write_state->sql_blob=NULL; } return ret;