JuliusBrussee/caveman · error

invalid sqlite page size

Error message

invalid sqlite page size

What it means

configureStorageBudget read a non-positive page_size PRAGMA from the SQLite database while setting up the max-/pages budget mapping. A healthy SQLite file always reports a positive page size, so this indicates a corrupt or non-SQLite file.

Source

Thrown at engine/ccr/store_sqlite.go:296

	}
	defer file.Close()
	opened, err := file.Stat()
	if err != nil {
		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

View on GitHub (pinned to 766dce6b13)

Solutions

  1. Point the store at a valid SQLite database file or a fresh path so one is created
  2. Inspect the file with 'PRAGMA integrity_check' and recreate it if corrupt
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at engine/ccr/store_sqlite.go:296 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/6620fb37c4d239f6. Report an issue: GitHub.