JuliusBrussee/caveman · error

budget is below SQLite minimum

Error message

budget %d is below SQLite minimum %d

What it means

Raised by configureStorageBudget: the byte budget divided by the database page size yields fewer than 16 pages, below SQLite's minimum database size. The configured budget is too small to hold any usable database, so opening fails rather than silently clamping.

Solutions

  1. Raise the budget to at least 16 * page_size bytes (the message states the minimum)
  2. Use the default budget instead of a tiny custom one
  3. Set CAVEMAN_CCR_MAX_BYTES to a value appropriate for real recovery payloads
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at engine/ccr/store_sqlite.go:300 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/e6a86ba02a9f92c5. Report an issue: GitHub.

Appendix: source

Thrown at engine/ccr/store_sqlite.go:300

		return err
	}
	if !os.SameFile(info, opened) {
		return fmt.Errorf("file changed while opening")
	}
	return file.Chmod(0o600)
}

func configureStorageBudget(db *sql.DB, maxBytes int64) error {
	var pageSize int64
	if err := db.QueryRow(`PRAGMA page_size`).Scan(&pageSize); err != nil {
		return fmt.Errorf("read page size: %w", err)
	}
	if pageSize <= 0 {
		return errors.New("invalid sqlite page size")
	}
	maxPages := maxBytes / pageSize
	if maxPages < 16 {
		return fmt.Errorf("budget %d is below SQLite minimum %d", maxBytes, 16*pageSize)
	}
	var applied int64
	if err := db.QueryRow(fmt.Sprintf(`PRAGMA max_page_count=%d`, maxPages)).Scan(&applied); err != nil {
		return err
	}
	if applied < maxPages {
		maxPages = applied
	}
	autoCheckpoint := maxPages / 16
	if autoCheckpoint < 1 {
		autoCheckpoint = 1
	}
	if _, err := db.Exec(fmt.Sprintf(`PRAGMA wal_autocheckpoint=%d`, autoCheckpoint)); err != nil {
		return err
	}
	_, err := db.Exec(fmt.Sprintf(`PRAGMA journal_size_limit=%d`, maxBytes/8))
	return err
}

View on GitHub (pinned to 766dce6b13)