mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
makes cache mode configurable
this makes the cache mode in the sqlite connection string configurable. the default also changed from shared to private to solve #107272 but allow the user to use shared if performance is more important. ref #10727
This commit is contained in:
parent
8a976f5cb4
commit
74124ec8ed
@ -103,6 +103,9 @@ server_cert_name =
|
|||||||
# For "sqlite3" only, path relative to data_path setting
|
# For "sqlite3" only, path relative to data_path setting
|
||||||
path = grafana.db
|
path = grafana.db
|
||||||
|
|
||||||
|
# For "sqlite3" only. cache mode setting used for connecting to the database
|
||||||
|
cache_mode = private
|
||||||
|
|
||||||
#################################### Session #############################
|
#################################### Session #############################
|
||||||
[session]
|
[session]
|
||||||
# Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file"
|
# Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file"
|
||||||
|
@ -99,6 +99,9 @@
|
|||||||
# Set to true to log the sql calls and execution times.
|
# Set to true to log the sql calls and execution times.
|
||||||
log_queries =
|
log_queries =
|
||||||
|
|
||||||
|
# For "sqlite3" only. cache mode setting used for connecting to the database. (private, shared)
|
||||||
|
;cache_mode = private
|
||||||
|
|
||||||
#################################### Session ####################################
|
#################################### Session ####################################
|
||||||
[session]
|
[session]
|
||||||
# Either "memory", "file", "redis", "mysql", "postgres", default is "file"
|
# Either "memory", "file", "redis", "mysql", "postgres", default is "file"
|
||||||
|
@ -250,6 +250,12 @@ Sets the maximum amount of time a connection may be reused. The default is 14400
|
|||||||
|
|
||||||
Set to `true` to log the sql calls and execution times.
|
Set to `true` to log the sql calls and execution times.
|
||||||
|
|
||||||
|
### cache_mode
|
||||||
|
|
||||||
|
For "sqlite3" only. [Shared cache](https://www.sqlite.org/sharedcache.html) setting used for connecting to the database. (private, shared)
|
||||||
|
Defaults to private.
|
||||||
|
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
## [security]
|
## [security]
|
||||||
|
@ -243,7 +243,7 @@ func (ss *SqlStore) buildConnectionString() (string, error) {
|
|||||||
ss.dbCfg.Path = filepath.Join(ss.Cfg.DataPath, ss.dbCfg.Path)
|
ss.dbCfg.Path = filepath.Join(ss.Cfg.DataPath, ss.dbCfg.Path)
|
||||||
}
|
}
|
||||||
os.MkdirAll(path.Dir(ss.dbCfg.Path), os.ModePerm)
|
os.MkdirAll(path.Dir(ss.dbCfg.Path), os.ModePerm)
|
||||||
cnnstr = "file:" + ss.dbCfg.Path + "?cache=shared&mode=rwc"
|
cnnstr = fmt.Sprintf("file:%s?cache=%s&mode=rwc", ss.dbCfg.Path, ss.dbCfg.CacheMode)
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("Unknown database type: %s", ss.dbCfg.Type)
|
return "", fmt.Errorf("Unknown database type: %s", ss.dbCfg.Type)
|
||||||
}
|
}
|
||||||
@ -319,6 +319,8 @@ func (ss *SqlStore) readConfig() {
|
|||||||
ss.dbCfg.ClientCertPath = sec.Key("client_cert_path").String()
|
ss.dbCfg.ClientCertPath = sec.Key("client_cert_path").String()
|
||||||
ss.dbCfg.ServerCertName = sec.Key("server_cert_name").String()
|
ss.dbCfg.ServerCertName = sec.Key("server_cert_name").String()
|
||||||
ss.dbCfg.Path = sec.Key("path").MustString("data/grafana.db")
|
ss.dbCfg.Path = sec.Key("path").MustString("data/grafana.db")
|
||||||
|
|
||||||
|
ss.dbCfg.CacheMode = sec.Key("cache_mode").MustString("private")
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitTestDB(t *testing.T) *SqlStore {
|
func InitTestDB(t *testing.T) *SqlStore {
|
||||||
@ -391,13 +393,20 @@ func IsTestDbPostgres() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DatabaseConfig struct {
|
type DatabaseConfig struct {
|
||||||
Type, Host, Name, User, Pwd, Path, SslMode string
|
Type string
|
||||||
CaCertPath string
|
Host string
|
||||||
ClientKeyPath string
|
Name string
|
||||||
ClientCertPath string
|
User string
|
||||||
ServerCertName string
|
Pwd string
|
||||||
ConnectionString string
|
Path string
|
||||||
MaxOpenConn int
|
SslMode string
|
||||||
MaxIdleConn int
|
CaCertPath string
|
||||||
ConnMaxLifetime int
|
ClientKeyPath string
|
||||||
|
ClientCertPath string
|
||||||
|
ServerCertName string
|
||||||
|
ConnectionString string
|
||||||
|
MaxOpenConn int
|
||||||
|
MaxIdleConn int
|
||||||
|
ConnMaxLifetime int
|
||||||
|
CacheMode string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user