fix: improve SQLite "database is locked" errors by increasing default SQLITE_TIMEOUT #11179

Merged
mfenniak merged 2 commits from mfenniak/forgejo:fix-SQLite-intermittent-test into forgejo 2026-02-09 21:31:19 +01:00
Member

As noted in #10900 (comment), TestAPICreateIssueParallel is failing intermittently in Forgejo CI. Based upon this intermittent failure, I've made these changes:

  • Increase the parallel run of the test from 10 instances to 100, which caused this test to fail consistently and reliably on my dev workstation. The test execution time at 100 parallel invocations is only ~4 seconds.
  • Increase the default SQLITE_TIMEOUT from 500ms to 5s, which caused this test to succeed consistently on my dev workstation.

Is 5000ms the right setting? 🤷 On local testing, this specific test failed...

  • 2500ms: failed 1/1 times
  • 3000ms: failed 1/3 times
  • 3500ms: failed 0/10 times

Checklist

The contributor guide contains information that will be helpful to first time contributors. There also are a few conditions for merging Pull Requests in Forgejo repositories. You are also welcome to join the Forgejo development chatroom.

Tests

  • I added test coverage for Go changes...
    • in their respective *_test.go for unit tests.
    • in the tests/integration directory if it involves interactions with a live Forgejo server.
  • I added test coverage for JavaScript changes...

Documentation

  • I created a pull request to the documentation to explain to Forgejo users how to use this change.
  • I did not document these changes and I do not expect someone else to do it.

Release notes

  • This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
  • This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

The decision if the pull request will be shown in the release notes is up to the mergers / release team.

The content of the release-notes/<pull request number>.md file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead.

Release notes

  • Bug fixes
    • PR: improve SQLite "database is locked" errors by increasing default SQLITE_TIMEOUT
As noted in https://codeberg.org/forgejo/forgejo/issues/10900#issuecomment-10339634, `TestAPICreateIssueParallel` is failing intermittently in Forgejo CI. Based upon this intermittent failure, I've made these changes: - Increase the parallel run of the test from 10 instances to 100, which caused this test to fail consistently and reliably on my dev workstation. The test execution time at 100 parallel invocations is only ~4 seconds. - Increase the default `SQLITE_TIMEOUT` from 500ms to 5s, which caused this test to succeed consistently on my dev workstation. Is 5000ms the right setting? 🤷 On local testing, this specific test failed... - 2500ms: failed 1/1 times - 3000ms: failed 1/3 times - 3500ms: failed 0/10 times ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change. - [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change. *The decision if the pull request will be shown in the release notes is up to the mergers / release team.* The content of the `release-notes/<pull request number>.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Bug fixes - [PR](https://codeberg.org/forgejo/forgejo/pulls/11179): <!--number 11179 --><!--line 0 --><!--description aW1wcm92ZSBTUUxpdGUgImRhdGFiYXNlIGlzIGxvY2tlZCIgZXJyb3JzIGJ5IGluY3JlYXNpbmcgZGVmYXVsdCBgU1FMSVRFX1RJTUVPVVRg-->improve SQLite "database is locked" errors by increasing default `SQLITE_TIMEOUT`<!--description--> <!--end release-notes-assistant-->
fix: increase default SQLITE_TIMEOUT to 5s
Some checks failed
testing / frontend-checks (pull_request) Successful in 1m5s
testing / backend-checks (pull_request) Successful in 3m6s
Integration tests for the release process / release-simulation (pull_request) Successful in 5m27s
testing / test-unit (pull_request) Successful in 6m25s
testing / test-remote-cacher (garnet) (pull_request) Successful in 2m7s
testing / test-remote-cacher (valkey) (pull_request) Successful in 2m10s
testing / test-remote-cacher (redict) (pull_request) Successful in 2m9s
testing / test-remote-cacher (redis) (pull_request) Successful in 2m16s
testing / test-e2e (pull_request) Successful in 18m38s
testing / test-mysql (pull_request) Successful in 21m41s
testing / test-sqlite (pull_request) Successful in 26m43s
testing / test-pgsql (pull_request) Successful in 29m58s
testing / security-check (pull_request) Successful in 45s
milestone / set (pull_request_target) Successful in 7s
issue-labels / cascade (pull_request_target) Has been skipped
issue-labels / backporting (pull_request_target) Failing after 42s
issue-labels / release-notes (pull_request_target) Successful in 49s
requirements / merge-conditions (pull_request) Successful in 4s
e7f168ba42
viceice approved these changes 2026-02-06 23:19:50 +01:00
viceice left a comment

let's test it on forgejo code.

let's test it on forgejo code.
Owner

[ ] I created a pull request to the documentation to explain to Forgejo users how to use this change.

Is needed

Also:

;SQLITE_TIMEOUT = ; Query timeout defaults to: 500

> [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. Is needed Also: https://codeberg.org/forgejo/forgejo/src/commit/7e4619df83b1269dc074ea2f7102b6424cbd3152/custom/conf/app.example.ini#L364
@ -229,3 +229,3 @@
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
for i := 0; i < 100; i++ {
Owner

Do we need to keep this change? Since with the new default we know there's quite a margin for it to not fail, in which case it can be reverted back to 10 to keep not failing.

Or it will be more informative to keep 100 so we're more likely to catch it failing and improve something else?

Do we need to keep this change? Since with the new default we know there's quite a margin for it to not fail, in which case it can be reverted back to 10 to keep not failing. Or it will be more informative to keep 100 so we're more likely to catch it failing and improve something else?
Author
Member

I've changed it to 100 with the intention that it will fail more consistently if the behaviour regresses.

I've changed it to 100 with the intention that it will fail more consistently if the behaviour regresses.
0ko marked this conversation as resolved
Author
Member

@0ko wrote in #11179 (comment):

[ ] I created a pull request to the documentation to explain to Forgejo users how to use this change.

Is needed

Agreed; I'm just going to wait for feedback from @viceice's testing.

@0ko wrote in https://codeberg.org/forgejo/forgejo/pulls/11179#issuecomment-10432050: > > [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. > > Is needed Agreed; I'm just going to wait for feedback from @viceice's testing.
Owner

@mfenniak wrote in #11179 (comment):

@0ko wrote in #11179 (comment):

[ ] I created a pull request to the documentation to explain to Forgejo users how to use this change.

Is needed

Agreed; I'm just going to wait for feedback from @viceice's testing.

I'll try to check the logs today afternoon 😅

@mfenniak wrote in https://codeberg.org/forgejo/forgejo/pulls/11179#issuecomment-10432112: > @0ko wrote in #11179 (comment): > > > > [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. > > > > > > Is needed > > Agreed; I'm just going to wait for feedback from @viceice's testing. I'll try to check the logs today afternoon 😅
Owner

it doesn't fix it fully but improves. see comment in issue

it doesn't fix it fully but improves. see comment in issue
mfenniak merged commit c0cb271f15 into forgejo 2026-02-09 21:31:19 +01:00
mfenniak deleted branch fix-SQLite-intermittent-test 2026-02-09 21:31:23 +01:00

The backport to v14.0/forgejo failed. Check the latest run for more details.

The backport to `v14.0/forgejo` failed. Check the latest run for more details.
Where does that come from? The following is a preview of the release notes for this pull request, as they will appear in the upcoming release. They are derived from the content of the `release-notes/11179.md` file, if it exists, or the title of the pull request. They were also added at the bottom of the description of this pull request for easier reference.

This message and the release notes originate from a call to the release-notes-assistant.

@@ -36,2 +36,10 @@
 
 The content of the `release-notes/<pull request number>.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead.
+
+<!--start release-notes-assistant-->
+
+## Release notes
+<!--URL:https://codeberg.org/forgejo/forgejo-->
+- Bug fixes
+  - [PR](https://codeberg.org/forgejo/forgejo/pulls/11179): <!--number 11179 --><!--line 0 --><!--description aW1wcm92ZSBTUUxpdGUgImRhdGFiYXNlIGlzIGxvY2tlZCIgZXJyb3JzIGJ5IGluY3JlYXNpbmcgZGVmYXVsdCBgU1FMSVRFX1RJTUVPVVRg-->improve SQLite "database is locked" errors by increasing default `SQLITE_TIMEOUT`<!--description-->
+<!--end release-notes-assistant-->

Release notes

  • Bug fixes
    • PR: improve SQLite "database is locked" errors by increasing default SQLITE_TIMEOUT
<details> <summary>Where does that come from?</summary> The following is a preview of the release notes for this pull request, as they will appear in the upcoming release. They are derived from the content of the `release-notes/11179.md` file, if it exists, or the title of the pull request. They were also added at the bottom of the description of this pull request for easier reference. This message and the release notes originate from a call to the [release-notes-assistant](https://code.forgejo.org/forgejo/release-notes-assistant). ```diff @@ -36,2 +36,10 @@ The content of the `release-notes/<pull request number>.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead. + +<!--start release-notes-assistant--> + +## Release notes +<!--URL:https://codeberg.org/forgejo/forgejo--> +- Bug fixes + - [PR](https://codeberg.org/forgejo/forgejo/pulls/11179): <!--number 11179 --><!--line 0 --><!--description aW1wcm92ZSBTUUxpdGUgImRhdGFiYXNlIGlzIGxvY2tlZCIgZXJyb3JzIGJ5IGluY3JlYXNpbmcgZGVmYXVsdCBgU1FMSVRFX1RJTUVPVVRg-->improve SQLite "database is locked" errors by increasing default `SQLITE_TIMEOUT`<!--description--> +<!--end release-notes-assistant--> ``` </details> <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Bug fixes - [PR](https://codeberg.org/forgejo/forgejo/pulls/11179): <!--number 11179 --><!--line 0 --><!--description aW1wcm92ZSBTUUxpdGUgImRhdGFiYXNlIGlzIGxvY2tlZCIgZXJyb3JzIGJ5IGluY3JlYXNpbmcgZGVmYXVsdCBgU1FMSVRFX1RJTUVPVVRg-->improve SQLite "database is locked" errors by increasing default `SQLITE_TIMEOUT`<!--description--> <!--end release-notes-assistant-->
Sign in to join this conversation.
No reviewers
No labels
arch
riscv64
backport/v1.19
backport/v1.20
backport/v1.21/forgejo
backport/v10.0/forgejo
backport/v11.0/forgejo
backport/v12.0/forgejo
backport/v13.0/forgejo
backport/v14.0/forgejo
backport/v15.0/forgejo
backport/v7.0/forgejo
backport/v8.0/forgejo
backport/v9.0/forgejo
breaking
bug
bug
confirmed
bug
duplicate
bug
needs-more-info
bug
new-report
bug
reported-upstream
code/actions
code/api
code/auth
code/auth/faidp
code/auth/farp
code/email
code/federation
code/git
code/migrations
code/packages
code/wiki
database
MySQL
database
PostgreSQL
database
SQLite
dependency-upgrade
dependency
Chi
dependency
Chroma
dependency
F3
dependency
ForgeFed
dependency
garage
dependency
Gitea
dependency
Golang
Discussion
duplicate
enhancement/feature
forgejo/accessibility
forgejo/branding
forgejo/ci
forgejo/commit-graph
forgejo/documentation
forgejo/furnace cleanup
forgejo/i18n
forgejo/interop
forgejo/moderation
forgejo/privacy
forgejo/release
forgejo/scaling
forgejo/security
forgejo/ui
Gain
High
Gain
Nice to have
Gain
Undefined
Gain
Very High
good first issue
i18n/backport-stable
impact
large
impact
medium
impact
small
impact
unknown
Incompatible license
issue
closed
issue
do-not-exist-yet
issue
open
manual test
Manually tested during feature freeze
OS
FreeBSD
OS
Linux
OS
macOS
OS
Windows
problem
QA
regression
release blocker
Release Cycle
Feature Freeze
release-blocker
v7.0
release-blocker
v7.0.1
release-blocker
v7.0.2
release-blocker
v7.0.3
release-blocker
v7.0.4
release-blocker
v8.0.0
release-blocker/v9.0.0
run-all-playwright-tests
run-end-to-end-tests
stage
2-research
stage
3-design
stage
4-implementation
test
manual
test
needed
test
needs-help
test
not-needed
test
present
untested
User research - time-tracker
valuable code
worth a release-note
User research - Accessibility
User research - Blocked
User research - Community
User research - Config (instance)
User research - Errors
User research - Filters
User research - Future backlog
User research - Git workflow
User research - Labels
User research - Moderation
User research - Needs input
User research - Notifications/Dashboard
User research - Rendering
User research - Repo creation
User research - Repo units
User research - Security
User research - Settings (in-app)
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/forgejo!11179
No description provided.