Skip to content

Use SQLite database backend #9954

Closed
Closed

Description

@calmh

This is a notice of intent to experiment. :) I tried to use a SQLite database backend several years ago and it turned out not great. There were several issues at the time; performance, lack of required concurrency in some cases, and difficulty in cross compilation. This time I intend to take a slightly different approach, with slightly different goals, and also things have changed in the wider ecosystem.

  • Instead of using it as a dumb key-value store I will use wider tables with at least some fields of the underlying data exposed as columns. The intention is to use native SQLite indexes and processes for a lot of the metadata housekeeping we do manually today.
  • If having long running write transactions is still a problem I'll work to split them up -- for example, having a puller iteration be for only a subset of files rather than all that are needed at the time. For ordering items (by size, modification time, etc) we can use SQL constructions with a limit clause.
  • There are multiple implementations of SQLite available, the most common being the regular C implementation with a wrapper, which we can use for most builds. For the more exotic builds there is a Go translation of the C source code, which is equally cross compilable to what we have today. We can use either or both as required.
  • I'm willing to accept a certain level of performance degradation if it results in improved stability and maintainability.

Activity

  1. added
    enhancement
    needs-triage
    on Feb 10, 2025
  2. bt90 commented on Feb 10, 2025

    @bt90
    Contributor

    Not sure if it makes sense for Syncthings database design, but it happens far too often that people use a single sqlite database for everything. Having multiple database files for unrelated data tends to avoid performance bottlenecks.

  3. deleted a comment from Bta386 on Feb 19, 2025
  4. added a commit that references this issue on Mar 29, 2025
    025905f
  5. added this to the v2.0.0 milestone on Mar 29, 2025
  6. Michael679089 commented on Apr 2, 2025

    @Michael679089

    Will the app's processes work faster now?

  7. bt90 commented on Apr 2, 2025

    @bt90
    Contributor

    This is not about speed. The main goal is durability.

  8. koro666 commented on Apr 9, 2025

    @koro666

    This is a good (and overdue) change, thank you. My main issue with .ldb files was that they seemed to be periodically fully rewritten, causing huge (multiple GBs) "incremental" backups every week.

    Plus, having them in a readable format will allow to go "poke" stuff in there when something gets stuck, such as one side absolutely claiming that a file which was deleted ages ago suddenly is back and unsynced, etc.

    Hopefully, the SQLite files will be in a separate directory which I can chattr +C (to avoid fragmentation).

  9. added
    frozen-due-to-age
    on Jul 1, 2026
  10. locked and limited conversation to collaborators on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrozen-due-to-ageneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions