From ca436db45277b379960ead29153b1a94751a39e6 Mon Sep 17 00:00:00 2001 From: Matthew Jacobson Date: Fri, 17 Jun 2022 12:19:05 -0400 Subject: [PATCH] Alerting: Fix AM config overwrite when SQLite db is locked during sync (#50951) (#51001) If SQLite is used and the database is locked temporarily (ex. heavy write-load) during periodic AM config sync, it was possible for your AM config to be overwritten with the default one. This fixes that by patching a bug in xorm v0.8.2 which was causing SQLITE_BUSY errors to be ignored in certain cases. (cherry picked from commit 8f5912b94c89b86fdd7615df612a7b6aff8a9166) --- go.mod | 5 +++++ go.sum | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index de03aee2a9c..3c5f2fc1447 100644 --- a/go.mod +++ b/go.mod @@ -293,3 +293,8 @@ replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.10.2 // TODO: remove once gocloud.dev releases 0.25.x // `fileblob` implementation has buggy key ordering in 0.24.0 replace gocloud.dev v0.24.0 => github.com/google/go-cloud v0.24.1-0.20220209172924-99801bbb523a + +// This is a patched v0.8.2 intended to fix session.Find (and others) silently ignoring SQLITE_BUSY errors. This could +// happen, for example, during a read when the sqlite db is under heavy write load. +// This patch cherry picks compatible fixes from upstream xorm PR#1998 and can be reverted on upgrade to xorm v1.2.0+. +replace xorm.io/xorm => github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6 diff --git a/go.sum b/go.sum index 25212ba5524..7663439252b 100644 --- a/go.sum +++ b/go.sum @@ -1379,6 +1379,8 @@ github.com/grafana/loki v1.6.2-0.20211015002020-7832783b1caa/go.mod h1:0O8o/juxN github.com/grafana/saml v0.0.0-20211007135653-aed1b2edd86b h1:YiSGp34F4V0G08HHx1cJBf2GVgwYAkXQjzuVs1t8jYk= github.com/grafana/saml v0.0.0-20211007135653-aed1b2edd86b/go.mod h1:q83kyQoMD0vhy+RzFLlbw0UgHJ6TAihQpuXvdFmm4s4= github.com/grafana/sqlds/v2 v2.3.2/go.mod h1:34uyqPBWsEvg4V/xxh6V4uIqwu1qLfOfsmScll/ukrk= +github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6 h1:I9dh1MXGX0wGyxdV/Sl7+ugnki4Dfsy8lv2s5Yf887o= +github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -3668,5 +3670,3 @@ xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU= xorm.io/core v0.7.2/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM= xorm.io/core v0.7.3 h1:W8ws1PlrnkS1CZU1YWaYLMQcQilwAmQXU0BJDJon+H0= xorm.io/core v0.7.3/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM= -xorm.io/xorm v0.8.2 h1:nbg1AyWn7iLrwp0Dqg8IrYOBkBYYJ85ry9bvZLVl4Ok= -xorm.io/xorm v0.8.2/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY=