From 5e11ccae69ae0431848c87b1c8f79efc3fbad909 Mon Sep 17 00:00:00 2001 From: Jonas Malaco Date: Wed, 3 Jan 2018 23:53:03 -0200 Subject: [PATCH] Set SQLite busy_timeout to prevent SQLITE_BUSY errors (see #8) --- CHANGES.md | 9 +++++++++ src/Server.hx | 2 ++ src/async/Handler.hx | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index fc21899..610a501 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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! diff --git a/src/Server.hx b/src/Server.hx index 34f622b..4f679e4 100644 --- a/src/Server.hx +++ b/src/Server.hx @@ -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"); diff --git a/src/async/Handler.hx b/src/async/Handler.hx index 25364ad..e6af199 100644 --- a/src/async/Handler.hx +++ b/src/async/Handler.hx @@ -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;