mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Database: Adds support for enable/disable SQLite Write-Ahead Logging (WAL) via configuration (#58268)
Adds support for enable/disable SQLite Write-Ahead Logging (WAL) via configuration. Enables SQLite WAL for E2E tests.
This commit is contained in:
committed by
GitHub
parent
df27164b8e
commit
79f1a7a4fd
@@ -134,6 +134,9 @@ path = grafana.db
|
||||
# For "sqlite3" only. cache mode setting used for connecting to the database
|
||||
cache_mode = private
|
||||
|
||||
# For "sqlite3" only. Enable/disable Write-Ahead Logging, https://sqlite.org/wal.html. Default is false.
|
||||
wal = false
|
||||
|
||||
# For "mysql" only if migrationLocking feature toggle is set. How many seconds to wait before failing to lock the database for the migrations, default is 0.
|
||||
locking_attempt_timeout_sec = 0
|
||||
|
||||
@@ -1147,7 +1150,7 @@ renderer_token = -
|
||||
# which this setting can help protect against by only allowing a certain amount of concurrent requests.
|
||||
concurrent_render_request_limit = 30
|
||||
# Determines the lifetime of the render key used by the image renderer to access and render Grafana.
|
||||
# This setting should be expressed as a duration. Examples: 10s (seconds), 5m (minutes), 2h (hours).
|
||||
# This setting should be expressed as a duration. Examples: 10s (seconds), 5m (minutes), 2h (hours).
|
||||
# Default is 5m. This should be more than enough for most deployments.
|
||||
# Change the value only if image rendering is failing and you see `Failed to get the render key from cache` in Grafana logs.
|
||||
render_key_lifetime = 5m
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
# For "sqlite3" only. cache mode setting used for connecting to the database. (private, shared)
|
||||
;cache_mode = private
|
||||
|
||||
# For "sqlite3" only. Enable/disable Write-Ahead Logging, https://sqlite.org/wal.html. Default is false.
|
||||
;wal = false
|
||||
|
||||
# For "mysql" only if migrationLocking feature toggle is set. How many seconds to wait before failing to lock the database for the migrations, default is 0.
|
||||
;locking_attempt_timeout_sec = 0
|
||||
|
||||
|
||||
@@ -380,6 +380,10 @@ will be stored.
|
||||
For "sqlite3" only. [Shared cache](https://www.sqlite.org/sharedcache.html) setting used for connecting to the database. (private, shared)
|
||||
Defaults to `private`.
|
||||
|
||||
### wal
|
||||
|
||||
For "sqlite3" only. Setting to enable/disable [Write-Ahead Logging](https://sqlite.org/wal.html). The default value is `false` (disabled).
|
||||
|
||||
### query_retries
|
||||
|
||||
This setting applies to `sqlite` only and controls the number of times the system retries a query when the database is locked. The default value is `0` (disabled).
|
||||
|
||||
@@ -325,6 +325,11 @@ func (ss *SQLStore) buildConnectionString() (string, error) {
|
||||
}
|
||||
|
||||
cnnstr = fmt.Sprintf("file:%s?cache=%s&mode=rwc", ss.dbCfg.Path, ss.dbCfg.CacheMode)
|
||||
|
||||
if ss.dbCfg.WALEnabled {
|
||||
cnnstr += "&_journal_mode=WAL"
|
||||
}
|
||||
|
||||
cnnstr += ss.buildExtraConnectionString('&')
|
||||
default:
|
||||
return "", fmt.Errorf("unknown database type: %s", ss.dbCfg.Type)
|
||||
@@ -453,6 +458,7 @@ func (ss *SQLStore) readConfig() error {
|
||||
ss.dbCfg.IsolationLevel = sec.Key("isolation_level").String()
|
||||
|
||||
ss.dbCfg.CacheMode = sec.Key("cache_mode").MustString("private")
|
||||
ss.dbCfg.WALEnabled = sec.Key("wal").MustBool(false)
|
||||
ss.dbCfg.SkipMigrations = sec.Key("skip_migrations").MustBool()
|
||||
ss.dbCfg.MigrationLockAttemptTimeout = sec.Key("locking_attempt_timeout_sec").MustInt()
|
||||
|
||||
@@ -677,6 +683,7 @@ type DatabaseConfig struct {
|
||||
MaxIdleConn int
|
||||
ConnMaxLifetime int
|
||||
CacheMode string
|
||||
WALEnabled bool
|
||||
UrlQueryParams map[string][]string
|
||||
SkipMigrations bool
|
||||
MigrationLockAttemptTimeout int
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
[feature_toggles]
|
||||
enable = publicDashboards
|
||||
|
||||
[database]
|
||||
type=sqlite3
|
||||
wal=true
|
||||
|
||||
Reference in New Issue
Block a user