Skip to content

Overhaul persistence #1525

Closed
9 of 9 issues completed
Closed

Description

@josecelano

We should review the database layer.

Context

Problem

Proposal

In the middle term (before adding more tables), we should:

  • Research to confirm if the current crate is the best one. Change it if it's not.
  • Add migrations.
  • Split the database trait into many different traits per context. Otherwise, it will end up having too many methods.
    I think I will implement the metrics persistence with the current drivers because I want to finish the[+] stats overhaul,[/+][-] stats overhaul,[/-] but we should consider implementing this epic before continuing to add more tables (complexity) to the current persistence layer, especially if we decide to change it.

cc @da2ce7

The work is split into sequential sub-issues so each step can be independently reviewed and merged. See the implementation plan in the comments below.

Sub-issues

Sub-issues

9 of 9 Issues completed
Loading 9 sub-issues

Activity

  1. added
    EPIC
    on May 16, 2025
  2. added theissue type on May 16, 2025
  3. josecelano commented on Mar 6, 2026

    @josecelano
    MemberAuthor
  4. self-assigned this
    on Apr 20, 2026
  5. pinned this issue on Apr 21, 2026
  6. added 2 commits that reference this issue on Apr 22, 2026
  7. josecelano commented on Apr 22, 2026

    @josecelano
    MemberAuthor

    Implementation Plan

    The implementation has been broken down into 9 sequential sub-issues. Each one is independently reviewable and mergeable into develop before PostgreSQL support is complete.

    The full specs have been merged into develop via PR #1702. Links below point to each spec file.


    Phase 1 — Make the change easy

    # Sub-issue Short description Spec Status
    1 1525-01 Persistence test coverage Add a Bash compatibility-matrix runner that tests the tracker against all supported SQLite, MySQL, and PostgreSQL versions 1525-01-persistence-test-coverage.md
    2 1525-02 qBittorrent E2E runner Add a Rust binary that runs a full seeder→tracker→leecher download using real qBittorrent clients in containers 1525-02-qbittorrent-e2e.md
    3 1525-03 Persistence benchmarking Add a benchmark runner (--before-image/--after-image CLI) that measures announce throughput so every subsequent step can be compared against a concrete baseline 1525-03-persistence-benchmarking.md
    4 1525-04 Split persistence traits Split the monolithic Database trait into four narrow context traits (SchemaMigrator, TorrentMetricsStore, WhitelistStore, AuthKeyStore) plus a blanket Database aggregate supertrait 1713-1525-04-split-persistence-traits.md
    4b 1525-04b Migrate consumers to narrow traits Replace every Arc<Box<dyn Database>> consumer with the specific narrow trait it actually needs; introduce DatabaseStores struct to replace Arc<Box<dyn Database>> in TrackerCoreContainer 1525-04b-migrate-consumers-to-narrow-traits.md
    5 1525-05 Migrate SQLite and MySQL to sqlx Replace r2d2/rusqlite/mysql with async sqlx connection pools for both existing drivers, without introducing PostgreSQL yet 1525-05-migrate-sqlite-and-mysql-to-sqlx.md
    6 1525-06 Introduce schema migrations Replace raw DDL with sqlx::migrate!() and add a legacy-bootstrap path that history-aligns pre-v4 databases 1525-06-introduce-schema-migrations.md
    7 1525-07 Align Rust and DB types Widen NumberOfDownloads from u32 to u64 and the corresponding columns from INTEGER to BIGINT via a versioned migration 1525-07-align-rust-and-db-types.md

    Phase 2 — Make the easy change

    # Sub-issue Short description Spec Status
    8 1525-08 Add PostgreSQL driver Add PostgreSQL as a first-class backend using async sqlx, with four history-aligned migrations, testcontainers-based driver tests, container config, and user-facing documentation 1525-08-add-postgresql-driver.md

    EPIC planning doc: 1525-overhaul-persistence.md

  8. added 2 commits that reference this issue on Apr 28, 2026
  9. 4 remaining items

  10. added a commit that references this issue on Apr 30, 2026
  11. added 4 commits that reference this issue on May 1, 2026
  12. added a commit that references this issue on May 1, 2026
  13. unpinned this issue on May 6, 2026
  14. added 4 commits that reference this issue on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

EPIC

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions