Skip to content

Commit 0f6bee8

Browse files
committed
Switch back to cgo-based SQLite driver
In our experience, the pure Go SQLite driver introduced in upstream cmgr v0.13.0 had issues handling a large number of concurrent requests (such as during major competitions). Operations would often fail due to SQLITE_BUSY errors. See also package issues [0][1][2][3][4][5]. Due to this issue, we had previously forced to roll back to upstream cmgr v0.12.0. By reverting back to the cgo-based driver, we can take advantage of the other fixes made since that release. [0]: https://gitlab.com/cznic/sqlite/-/issues/74 [1]: https://gitlab.com/cznic/sqlite/-/issues/115 [2]: https://gitlab.com/cznic/sqlite/-/issues/126 [3]: https://gitlab.com/cznic/sqlite/-/issues/142 [4]: https://gitlab.com/cznic/sqlite/-/issues/146 [5]: https://gitlab.com/cznic/sqlite/-/issues/161
1 parent 749f372 commit 0f6bee8

File tree

4 files changed

+35
-235
lines changed

4 files changed

+35
-235
lines changed

NOTICE.release

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,30 @@ OTHER DEALINGS IN THE SOFTWARE.
8787

8888
------------------------------------------------------------------------------
8989

90-
This work uses the 'modernc.org/sqlite' module for Go:
90+
This work uses the 'github.com/mattn/go-sqlite3' module for Go:
9191

92-
Copyright (c) 2017 The Sqlite Authors. All rights reserved.
92+
go-sqlite3
93+
The MIT License (MIT)
9394

94-
Redistribution and use in source and binary forms, with or without
95-
modification, are permitted provided that the following conditions are met:
96-
97-
1. Redistributions of source code must retain the above copyright notice, this
98-
list of conditions and the following disclaimer.
99-
100-
2. Redistributions in binary form must reproduce the above copyright notice,
101-
this list of conditions and the following disclaimer in the documentation
102-
and/or other materials provided with the distribution.
103-
104-
3. Neither the name of the copyright holder nor the names of its contributors
105-
may be used to endorse or promote products derived from this software without
106-
specific prior written permission.
107-
108-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
109-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
110-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
111-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
112-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
113-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
114-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
115-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
116-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
117-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95+
Copyright (c) 2014 Yasuhiro Matsumoto
96+
97+
Permission is hereby granted, free of charge, to any person obtaining a copy
98+
of this software and associated documentation files (the "Software"), to deal
99+
in the Software without restriction, including without limitation the rights
100+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
101+
copies of the Software, and to permit persons to whom the Software is
102+
furnished to do so, subject to the following conditions:
103+
104+
The above copyright notice and this permission notice shall be included in all
105+
copies or substantial portions of the Software.
106+
107+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
108+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
109+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
110+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
111+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
112+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
113+
SOFTWARE.
118114

119115
------------------------------------------------------------------------------
120116

cmgr/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"reflect"
88

99
"github.com/jmoiron/sqlx"
10-
_ "modernc.org/sqlite"
10+
_ "github.com/mattn/go-sqlite3"
1111
)
1212

1313
const schemaQuery string = `
@@ -179,7 +179,7 @@ func (m *Manager) initDatabase() error {
179179
dbPath = "cmgr.db"
180180
}
181181

182-
db, err := sqlx.Open("sqlite", dbPath+"?_pragma=foreign_keys(1)")
182+
db, err := sqlx.Open("sqlite3", dbPath+"?_fk=true")
183183
if err != nil {
184184
m.log.errorf("could not open database: %s", err)
185185
return err

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ require (
1010
github.com/docker/docker v20.10.13+incompatible
1111
github.com/docker/go-connections v0.4.0
1212
github.com/docker/go-units v0.4.0
13-
github.com/gogo/googleapis v1.4.1 // indirect
1413
github.com/jmoiron/sqlx v1.3.4
15-
github.com/klauspost/compress v1.15.0 // indirect
16-
github.com/moby/sys/mountinfo v0.6.0 // indirect
17-
github.com/moby/sys/signal v0.7.0 // indirect
14+
github.com/mattn/go-sqlite3 v1.14.9
1815
github.com/opencontainers/image-spec v1.0.2 // indirect
1916
github.com/yuin/goldmark v1.4.2
2017
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
2118
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
2219
google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6 // indirect
2320
google.golang.org/grpc v1.45.0 // indirect
2421
gopkg.in/yaml.v2 v2.4.0
25-
modernc.org/sqlite v1.14.6
2622
)

0 commit comments

Comments
 (0)