MCPcopy Index your code
hub / github.com/dnote/dnote / StartWALCheckpointing

Function StartWALCheckpointing

pkg/server/database/database.go:111–123  ·  view source on GitHub ↗

StartWALCheckpointing starts a background goroutine that periodically checkpoints the WAL file to prevent it from growing unbounded

(db *gorm.DB, interval time.Duration)

Source from the content-addressed store, hash-verified

109// StartWALCheckpointing starts a background goroutine that periodically
110// checkpoints the WAL file to prevent it from growing unbounded
111func StartWALCheckpointing(db *gorm.DB, interval time.Duration) {
112 go func() {
113 ticker := time.NewTicker(interval)
114 defer ticker.Stop()
115
116 for range ticker.C {
117 // TRUNCATE mode removes the WAL file after checkpointing
118 if err := db.Exec("PRAGMA wal_checkpoint(TRUNCATE)").Error; err != nil {
119 log.ErrorWrap(err, "WAL checkpoint failed")
120 }
121 }
122 }()
123}
124
125// StartPeriodicVacuum runs full VACUUM on a schedule to reclaim space and defragment.
126// VACUUM acquires an exclusive lock and blocks all database operations briefly.

Callers 1

startCmdFunction · 0.92

Calls 2

ErrorWrapFunction · 0.92
ExecMethod · 0.65

Tested by

no test coverage detected