Skip to content

Commit

Permalink
Set SQLite busy_timeout to prevent SQLITE_BUSY errors (see #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasmalacofilho committed Jan 4, 2018
1 parent a6f6d55 commit 5e11cca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## Current merge window

To be released. Expected January 4th, 2018.

Fixes after first day of heavy load.

- Set SQLite busy_timeout to prevent SQLITE_BUSY errors (see #8)


## Patch release: v1.0.2

January 2nd, 2018... Happy new year!
Expand Down
2 changes: 2 additions & 0 deletions src/Server.hx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Server {
sys.db.Manager.initialize();

assert(cnx.dbName() == "SQLite");
cnx.request("PRAGMA busy_timeout=5000");
trace('sqlite: busy_timeout set');
var journalMode = cnx.request("PRAGMA journal_mode").getResult(0);
if (journalMode == "delete") {
cnx.request("PRAGMA page_size=4096");
Expand Down
3 changes: 2 additions & 1 deletion src/async/Handler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Handler {
var inst:Queue = Module.local().getExports()[NAME];
if (inst != null) {
Server.shortId = Server.requestId = 'async-${crypto.Random.global.readHex(2)}';
trace('async: init handler (${Server.codeVersion})');
sys.db.Manager.cnx.request("PRAGMA busy_timeout=10000");
trace('async: init handler, busy_timeout extended (${Server.codeVersion})');
var h = new Handler(inst);
h.loop();
return true;
Expand Down

0 comments on commit 5e11cca

Please sign in to comment.