Skip to content

Commit 5d57c28

Browse files
authored
Fix sqlite3 test (#32622)
1 parent c363bd0 commit 5d57c28

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/integration/api_issue_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ func TestAPICreateIssue(t *testing.T) {
144144

145145
func TestAPICreateIssueParallel(t *testing.T) {
146146
defer tests.PrepareTestEnv(t)()
147+
148+
// FIXME: There seems to be a bug in github.com/mattn/go-sqlite3 with sqlite_unlock_notify, when doing concurrent writes to the same database,
149+
// some requests may get stuck in "go-sqlite3.(*SQLiteRows).Next", "go-sqlite3.(*SQLiteStmt).exec" and "go-sqlite3.unlock_notify_wait",
150+
// because the "unlock_notify_wait" never returns and the internal lock never gets releases.
151+
//
152+
// The trigger is: a previous test created issues and made the real issue indexer queue start processing, then this test does concurrent writing.
153+
// Adding this "Sleep" makes go-sqlite3 "finish" some internal operations before concurrent writes and then won't get stuck.
154+
// To reproduce: make a new test run these 2 tests enough times:
155+
// > func TestBug() { for i := 0; i < 100; i++ { testAPICreateIssue(t); testAPICreateIssueParallel(t) } }
156+
// Usually the test gets stuck in fewer than 10 iterations without this "sleep".
157+
time.Sleep(time.Second)
158+
147159
const body, title = "apiTestBody", "apiTestTitle"
148160

149161
repoBefore := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})

0 commit comments

Comments
 (0)