MCPcopy Create free account
hub / github.com/cloudbase/garm / startSQLiteMaintenance

Method startSQLiteMaintenance

database/sql/sql.go:152–167  ·  view source on GitHub ↗

startSQLiteMaintenance runs periodic WAL checkpoint and VACUUM on both the main database and the objects database (if present). This reclaims disk space from deleted rows/blobs and keeps the WAL file from growing unbounded.

()

Source from the content-addressed store, hash-verified

150// main database and the objects database (if present). This reclaims disk space
151// from deleted rows/blobs and keeps the WAL file from growing unbounded.
152func (s *sqlDatabase) startSQLiteMaintenance() {
153 ticker := time.NewTicker(24 * time.Hour)
154 defer ticker.Stop()
155
156 for {
157 select {
158 case <-s.ctx.Done():
159 return
160 case <-ticker.C:
161 s.runSQLiteMaintenance(s.conn, "main")
162 if s.objectsConn != nil {
163 s.runSQLiteMaintenance(s.objectsConn, "objects")
164 }
165 }
166 }
167}
168
169func (s *sqlDatabase) runSQLiteMaintenance(conn *gorm.DB, dbName string) {
170 if err := conn.Exec("PRAGMA wal_checkpoint(TRUNCATE)").Error; err != nil {

Callers 1

NewSQLDatabaseFunction · 0.95

Calls 3

runSQLiteMaintenanceMethod · 0.95
StopMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected