Skip to content

Conversation

@utkuozdemir
Copy link
Member

Do not expose the base parameters, as they are required for COSI to work correctly.

Add a flag for the additional parameters, which can for example be used for configuring the SQLite db to be "suitable" for litestream to be able to make backups of it.

Also, add _pragma=synchronous(NORMAL) to the base parameters, as it is recommended for better performance when WAL mode is enabled.

@github-project-automation github-project-automation bot moved this from In Review to Approved in Planning Nov 27, 2025
Copilot finished reviewing on behalf of utkuozdemir November 27, 2025 12:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for passing extra connection string parameters to the SQLite database used for secondary storage. It refactors the SQLite connection logic into a dedicated package, adds the _pragma=synchronous(NORMAL) parameter to improve performance with WAL mode, and introduces a new CLI flag to allow users to configure additional DSN parameters (e.g., for litestream backup compatibility).

Key changes:

  • Introduces ExtraParams field in the SQLite configuration struct
  • Creates new internal/backend/runtime/omni/sqlite package with OpenDB function
  • Adds _pragma=synchronous(NORMAL) to base SQLite connection parameters

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/pkg/config/storage.go Adds ExtraParams field to the SQLite config struct
internal/backend/runtime/omni/sqlite/sqlite.go New package containing OpenDB function with base SQLite connection parameters including the new synchronous pragma
internal/backend/runtime/omni/state_sqlite.go Refactored to use the new OpenDB function and accept full config struct instead of just path
internal/backend/runtime/omni/state.go Updated function call to pass entire SQLite config struct
cmd/omni/cmd/cmd.go Adds new CLI flag --sqlite-storage-extra-params for configuring additional DSN parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dsn += "&" + config.ExtraParams
}

logger.Info("open sqlite database", zap.String("dsn", dsn))
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DSN is logged in plaintext, which may expose sensitive connection parameters if users include passwords or other credentials in ExtraParams. Consider sanitizing the DSN before logging, or log only the path and parameter names without their values.

Copilot uses AI. Check for mistakes.

// BaseParams are the base DSN parameters used for SQLite connections.
const BaseParams = "_txlock=immediate&_pragma=busy_timeout(50000)&_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)"

Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exported function OpenDB lacks a documentation comment. Add a comment describing the function's purpose, parameters, and return values following Go conventions (e.g., "OpenDB opens a SQLite database connection with the configured parameters and returns the database handle.").

Suggested change
// OpenDB opens a SQLite database connection using the provided configuration and logger.
// It ensures the database directory exists, constructs the DSN with base and extra parameters,
// and returns the database handle (*sql.DB) or an error if the connection fails.

Copilot uses AI. Check for mistakes.
@utkuozdemir utkuozdemir force-pushed the feat/customizable-sqlite-dsn-params branch 2 times, most recently from 3dcaa3e to 3f70ecb Compare November 27, 2025 13:15
Do not expose the base parameters, as they are required for COSI to work correctly.

Add a flag for the additional parameters, which can for example be used for configuring the SQLite db to be "suitable" for litestream to be able to make backups of it.

Also, add `_pragma=synchronous(NORMAL)` to the base parameters, as it is recommended for better performance when WAL mode is enabled.

Signed-off-by: Utku Ozdemir <[email protected]>
@utkuozdemir utkuozdemir force-pushed the feat/customizable-sqlite-dsn-params branch from 3f70ecb to 5e8ef87 Compare November 27, 2025 13:36
@utkuozdemir
Copy link
Member Author

/m

@talos-bot talos-bot merged commit 5e8ef87 into siderolabs:main Nov 27, 2025
27 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Planning Nov 27, 2025
@utkuozdemir utkuozdemir deleted the feat/customizable-sqlite-dsn-params branch November 27, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants