Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
05f31e45
Commit
05f31e45
authored
Jan 20, 2026
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add mmap size setting to database connection to prevent OOM errors
parent
55231820
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
sqlite.go
store/db/sqlite/sqlite.go
+2
-1
No files found.
store/db/sqlite/sqlite.go
View file @
05f31e45
...
@@ -33,6 +33,7 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
...
@@ -33,6 +33,7 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
// good practice to be explicit and prevent future surprises on SQLite upgrades.
// good practice to be explicit and prevent future surprises on SQLite upgrades.
// - Journal mode set to WAL: it's the recommended journal mode for most applications
// - Journal mode set to WAL: it's the recommended journal mode for most applications
// as it prevents locking issues.
// as it prevents locking issues.
// - mmap size set to 0: it disables memory mapping, which can cause OOM errors on some systems.
//
//
// Notes:
// Notes:
// - When using the `modernc.org/sqlite` driver, each pragma must be prefixed with `_pragma=`.
// - When using the `modernc.org/sqlite` driver, each pragma must be prefixed with `_pragma=`.
...
@@ -41,7 +42,7 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
...
@@ -41,7 +42,7 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
// - https://pkg.go.dev/modernc.org/sqlite#Driver.Open
// - https://pkg.go.dev/modernc.org/sqlite#Driver.Open
// - https://www.sqlite.org/sharedcache.html
// - https://www.sqlite.org/sharedcache.html
// - https://www.sqlite.org/pragma.html
// - https://www.sqlite.org/pragma.html
sqliteDB
,
err
:=
sql
.
Open
(
"sqlite"
,
profile
.
DSN
+
"?_pragma=foreign_keys(0)&_pragma=busy_timeout(10000)&_pragma=journal_mode(WAL)"
)
sqliteDB
,
err
:=
sql
.
Open
(
"sqlite"
,
profile
.
DSN
+
"?_pragma=foreign_keys(0)&_pragma=busy_timeout(10000)&_pragma=journal_mode(WAL)
&_pragma=mmap_size(0)
"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"failed to open db with dsn: %s"
,
profile
.
DSN
)
return
nil
,
errors
.
Wrapf
(
err
,
"failed to open db with dsn: %s"
,
profile
.
DSN
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment