Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Retry up to NTRIES times in get_pragma() when sqlite fails with SQLITE_BUSY. This function is called outside of a transaction and so isn't handled by the retries in pkgdb_transaction_begin().
Jan Mikkelsen committed 12 years ago
commit a44a5e72f9ac433c65af2011e3e6e834905758ef
parent 71f015e
1 file changed +7 -1
modified libpkg/pkgdb.c
@@ -3087,6 +3087,7 @@ get_pragma(sqlite3 *s, const char *sql, int64_t *res, bool silence)
{
	sqlite3_stmt	*stmt;
	int		 ret;
+
	int		 tries;

	assert(s != NULL && sql != NULL);

@@ -3097,7 +3098,12 @@ get_pragma(sqlite3 *s, const char *sql, int64_t *res, bool silence)
		return (EPKG_OK);
	}

-
	ret = sqlite3_step(stmt);
+
	for (tries = 0; tries < NTRIES; tries++) {
+
		ret = sqlite3_step(stmt);
+
		if (ret != SQLITE_BUSY)
+
			break;
+
		sqlite3_sleep(250);
+
	}

	if (ret == SQLITE_ROW)
		*res = sqlite3_column_int64(stmt, 0);