MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / startWALCheckpointer

Method startWALCheckpointer

internal/store/store.go:192–210  ·  view source on GitHub ↗

startWALCheckpointer runs PRAGMA wal_checkpoint(TRUNCATE) on a timer so the WAL file can't grow without bound. SQLite's automatic wal_autocheckpoint is PASSIVE: it can only checkpoint frames no reader still needs and never truncates the file. Pad's web UI keeps a steady stream of pollers (dashboard/

()

Source from the content-addressed store, hash-verified

190// checkpoint (readers active) just retries next tick. SQLite-only —
191// Close() stops it; the Postgres constructor never calls this.
192func (s *Store) startWALCheckpointer() {
193 s.stopMaint = make(chan struct{})
194 s.maintDone = make(chan struct{})
195 go func() {
196 defer close(s.maintDone)
197 ticker := time.NewTicker(walCheckpointInterval)
198 defer ticker.Stop()
199 for {
200 select {
201 case <-s.stopMaint:
202 return
203 case <-ticker.C:
204 if _, err := s.db.Exec("PRAGMA wal_checkpoint(TRUNCATE)"); err != nil {
205 slog.Warn("wal checkpoint failed", "error", err)
206 }
207 }
208 }
209 }()
210}
211
212// openPostgresDB opens and configures a PostgreSQL connection pool.
213func openPostgresDB(connStr string) (*sql.DB, error) {

Callers 1

NewFunction · 0.95

Calls 3

closeFunction · 0.85
ExecMethod · 0.80
StopMethod · 0.45

Tested by

no test coverage detected