|
@@ -56,6 +56,15 @@ namespace InvercargillSql {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Opens the database connection.
|
|
* Opens the database connection.
|
|
|
|
|
+ *
|
|
|
|
|
+ * A 5-second busy timeout is applied so concurrent readers (another
|
|
|
|
|
+ * process inspecting the store, a second connection) make writers
|
|
|
|
|
+ * wait instead of failing immediately with "database is locked",
|
|
|
|
|
+ * and WAL journaling is enabled where available so readers never
|
|
|
|
|
+ * block the writer at all. Both pragmas are best effort: a
|
|
|
|
|
+ * filesystem or build without WAL support falls back silently to
|
|
|
|
|
+ * the defaults.
|
|
|
|
|
+ *
|
|
|
* @throws SqlError if the connection cannot be opened
|
|
* @throws SqlError if the connection cannot be opened
|
|
|
*/
|
|
*/
|
|
|
public void open() throws SqlError {
|
|
public void open() throws SqlError {
|
|
@@ -67,6 +76,12 @@ namespace InvercargillSql {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
_is_open = true;
|
|
_is_open = true;
|
|
|
|
|
+ _db.busy_timeout(5000);
|
|
|
|
|
+ try {
|
|
|
|
|
+ execute("PRAGMA journal_mode=WAL");
|
|
|
|
|
+ } catch (SqlError e) {
|
|
|
|
|
+ // Best effort only.
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|