lightninglabs / lightninglabs/taproot-assets

[feature]: add sqlite database integrity checks to aid troubleshooting

Open
#758 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

database enhancement sqlite
Dominant language
Go
Stars
525
Forks
150
Avg merge
2d 15h
Merged PRs (30d)
31

Description

A user on Slack encountered a SQLite database foreign key constraint violation error when starting `tapd`. To address this, it's proposed that `tapd` should optionally perform SQLite database integrity checks during startup. This enhancement will be controlled by a new command line argument flag.

## Proposed Changes

- Modify the `sql.Open` call in the function `NewSqliteStore` to include debug/integrity check pragma options. This function is instantiated at startup in the `tapcfg/server.go` file ([source](https://github.com/lightninglabs/taproot-assets/blob/99c3e7952ec2050c0a38ce627c220f7dd0195f06/tapcfg/server.go#L53-L53)).

- Implement SQLite "pragma" options for integrity checks. Relevant options are [foreign_key_check](https://www.sqlite.org/pragma.html#pragma_foreign_key_check) and [integrity_check](https://www.sqlite.org/pragma.html#pragma_integrity_check). These two checks do not seem to overlap and can be included for comprehensive validation.

- Introduce a command line argument flag to control the execution of these checks, as they may significantly slow down `tapd` startup.

A list of SQLite "pragma" options can be found [here](https://www.sqlite.org/pragma.html).

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.

Research direction

Start at NewSqliteStore and the startup wiring in tapcfg/server.go, then review how the sql.Open call and command-line arguments are configured. The change is complete when an optional flag controls the SQLite foreign_key_check and integrity_check pragmas during startup without imposing those checks by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sqlite
Domain
cli, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.