From e8829170e5b4afe1fb6970c045c5e424a6e720f4 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 6 Apr 2023 15:06:16 +0200 Subject: [PATCH] feat(sqlite): use busy_timeout pragma to prevent database locking errors --- go.mod | 2 +- go.sum | 2 ++ internal/agent/controller/app/app_handler.go | 2 +- internal/config/database.go | 2 +- misc/packaging/common/config-server.yml | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 7aec0db..4c9b148 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module forge.cadoles.com/Cadoles/emissary go 1.19 require ( - forge.cadoles.com/arcad/edge v0.0.0-20230405131922-006f13bc7b88 + forge.cadoles.com/arcad/edge v0.0.0-20230406125812-4bc2d864ad1b github.com/Masterminds/sprig/v3 v3.2.3 github.com/alecthomas/participle/v2 v2.0.0-beta.5 github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 diff --git a/go.sum b/go.sum index d9d7a06..df28009 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= forge.cadoles.com/arcad/edge v0.0.0-20230405131922-006f13bc7b88 h1:d+AXw/Kx8X7M4GvtPC/mkZWK3tRMT051XORAiQAnClA= forge.cadoles.com/arcad/edge v0.0.0-20230405131922-006f13bc7b88/go.mod h1:Vx4iq/oewXUOkGyi8QKc14clTLNO1sWpb0SjBYELlAs= +forge.cadoles.com/arcad/edge v0.0.0-20230406125812-4bc2d864ad1b h1:B2M+lOgaCFOqUEsyiUBRUpOVk6yY7XRlRJVwfb0WXnA= +forge.cadoles.com/arcad/edge v0.0.0-20230406125812-4bc2d864ad1b/go.mod h1:Vx4iq/oewXUOkGyi8QKc14clTLNO1sWpb0SjBYELlAs= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg= github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= diff --git a/internal/agent/controller/app/app_handler.go b/internal/agent/controller/app/app_handler.go index a1d5cda..f5cb15a 100644 --- a/internal/agent/controller/app/app_handler.go +++ b/internal/agent/controller/app/app_handler.go @@ -30,7 +30,7 @@ import ( "gitlab.com/wpetit/goweb/logger" ) -const defaultSQLiteParams = "?_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_txlock=immediate" +const defaultSQLiteParams = "?_pragma=foreign_keys(1)&_pragma=busy_timeout=60000" func (c *Controller) getHandlerOptions(ctx context.Context, appKey string, specs *spec.Spec) ([]edgeHTTP.HandlerOptionFunc, error) { dataDir, err := c.ensureAppDataDir(ctx, appKey) diff --git a/internal/config/database.go b/internal/config/database.go index 566c83a..1714c55 100644 --- a/internal/config/database.go +++ b/internal/config/database.go @@ -15,6 +15,6 @@ type DatabaseConfig struct { func NewDefaultDatabaseConfig() DatabaseConfig { return DatabaseConfig{ Driver: "sqlite", - DSN: "sqlite://emissary.sqlite?_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_txlock=immediate", + DSN: "sqlite://emissary.sqlite?_pragma=foreign_keys(1)&_pragma=busy_timeout=60000", } } diff --git a/misc/packaging/common/config-server.yml b/misc/packaging/common/config-server.yml index d4b7ae7..ee6a542 100644 --- a/misc/packaging/common/config-server.yml +++ b/misc/packaging/common/config-server.yml @@ -9,7 +9,7 @@ server: port: 3000 database: driver: sqlite - dsn: sqlite:///var/lib/emissary/data.sqlite?_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_txlock=immediate + dsn: sqlite:///var/lib/emissary/data.sqlite?_pragma=foreign_keys(1)&_pragma=busy_timeout=60000 cors: allowedOrigins: [] allowCredentials: true