mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-16 11:41:19 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61bd0c8bdd |
No files matched your search
@@ -158,11 +158,11 @@ func DefaultConfig(driver Driver, dsn string) Config {
|
||||
SQLite: SQLiteOptions{
|
||||
PerformanceProfile: SQLiteProfileBalanced,
|
||||
BusyTimeout: 5 * time.Second,
|
||||
CacheSizeKB: 16 * 1024,
|
||||
CacheSizeKB: 4 * 1024,
|
||||
TempStoreMemory: false,
|
||||
MMapSizeBytes: 32 * 1024 * 1024,
|
||||
MMapSizeBytes: 0,
|
||||
WALAutoCheckpoint: 4000,
|
||||
JournalSizeLimitBytes: 16 * 1024 * 1024,
|
||||
JournalSizeLimitBytes: 4 * 1024 * 1024,
|
||||
},
|
||||
RollupPolicy: RollupPolicy{
|
||||
RawRetention: 10 * time.Minute,
|
||||
|
||||
+7
-4
@@ -247,16 +247,19 @@ func prepareSQLiteConfig(cfg Config) (Config, error) {
|
||||
cfg.SQLite.BusyTimeout = 5 * time.Second
|
||||
}
|
||||
if cfg.SQLite.CacheSizeKB == 0 {
|
||||
cfg.SQLite.CacheSizeKB = 16 * 1024
|
||||
cfg.SQLite.CacheSizeKB = 4 * 1024
|
||||
}
|
||||
if cfg.SQLite.MMapSizeBytes == 0 {
|
||||
cfg.SQLite.MMapSizeBytes = 32 * 1024 * 1024
|
||||
// MMapSizeBytes == 0 表示显式禁用 mmap,而不是"未设置":DefaultConfig 始终
|
||||
// 填充 SQLiteOptions,因此这里的 0 是"跳过 mmap"的明确选择,不能被覆盖为
|
||||
// 32MB。负数视为非法输入,归一为 0(禁用)。
|
||||
if cfg.SQLite.MMapSizeBytes < 0 {
|
||||
cfg.SQLite.MMapSizeBytes = 0
|
||||
}
|
||||
if cfg.SQLite.WALAutoCheckpoint == 0 {
|
||||
cfg.SQLite.WALAutoCheckpoint = 4000
|
||||
}
|
||||
if cfg.SQLite.JournalSizeLimitBytes == 0 {
|
||||
cfg.SQLite.JournalSizeLimitBytes = 16 * 1024 * 1024
|
||||
cfg.SQLite.JournalSizeLimitBytes = 4 * 1024 * 1024
|
||||
}
|
||||
|
||||
if cfg.DB == nil {
|
||||
|
||||
@@ -213,8 +213,8 @@ func TestSQLiteInDirCreatesDirectoryAndAppliesPragmas(t *testing.T) {
|
||||
if err := store.db.QueryRowContext(ctx, "PRAGMA journal_size_limit").Scan(&journalSizeLimit); err != nil {
|
||||
t.Fatalf("query journal size limit: %v", err)
|
||||
}
|
||||
if journalSizeLimit != 16*1024*1024 {
|
||||
t.Fatalf("journal size limit = %d, want %d", journalSizeLimit, 16*1024*1024)
|
||||
if journalSizeLimit != 4*1024*1024 {
|
||||
t.Fatalf("journal size limit = %d, want %d", journalSizeLimit, 4*1024*1024)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user