Bug: issue-backend tests fail with SQLite migration UNIQUE constraint error when run in parallel

Open Beginner friendly
#154 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rust, sqlite
Domain
databases, testing

Research direction

Start in crates/issue-backend/src/lib.rs, focusing on the tests that call db::connect("sqlite::memory:") and the migration setup involving MIGRATOR.run(). Run the affected SQLite and GitHub backend tests concurrently, then confirm each test has an isolated in-memory database and no _sqlx_migrations UNIQUE constraint errors.

Written by the indexing model from the issue text.

Description

bug

Summary

The tests in crates/issue-backend/src/lib.rs that use db::connect("sqlite::memory:") fail with:

UNIQUE constraint failed: _sqlx_migrations.version

When multiple async tests run concurrently and all call db::connect("sqlite::memory:"), they share the same in-memory database pool (since the URL is the same). The second test to call MIGRATOR.run() fails because the migration records are already present.

Affected tests

All 19 of the SQLite-based and GitHub backend tests fail (15 pass, 19 fail).

Expected behavior

Each test should get its own isolated in-memory SQLite database.

Suggested fix

Use unique connection strings per test, e.g. sqlite::memory:?cache=private or use sqlx::test(migrator = "MIGRATOR") pattern like the db crate's own tests do.

Discovered in

Branch qtua-gh-147-pluggable-issue-backends-sqlite-github-shell, commit a112f23.

Dominant language
Rust
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from drufball/ns2

All issues in drufball/ns2

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.