[libgda] sqlite: retry statements when database is busy



commit b7cb38c903908be6c2b6a629b7770bf3234063de
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Oct 8 13:22:31 2018 -0500

    sqlite: retry statements when database is busy
    
    This improvement, voids fails on parallel testing on
    meson.
    
    Try 10 times before fail.

 libgda/sqlite/gda-sqlite-provider.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index b4268db15..2be076725 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -3689,6 +3689,17 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                 /* actually execute the command */
                 handle = SQLITE3_CALL (sqlite3_db_handle) (ps->sqlite_stmt);
                 status = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
+                guint tries = 0;
+                while (status == SQLITE_BUSY) {
+                        if (gda_statement_get_statement_type (stmt) == GDA_SQL_STATEMENT_COMMIT) {
+                                break;
+                        }
+                        status = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
+                        if (tries == 10) {
+                                break;
+                        }
+                        tries++;
+                }
                 changes = SQLITE3_CALL (sqlite3_changes) (handle);
                 if (status != SQLITE_DONE) {
                         if (SQLITE3_CALL (sqlite3_errcode) (handle) != SQLITE_OK) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]