JuliusBrussee/caveman · error

read page size

Error message

read page size: %w

What it means

Wraps the PRAGMA page_size query failure in configureStorageBudget. The page size is needed to convert the byte budget into a max-page count; if it cannot be read (locked or broken database), budget enforcement cannot be set up and opening fails.

Solutions

  1. Check the wrapped error for lock or corruption causes
  2. Ensure no other process holds the database while it is being opened
  3. Recreate the database if it is corrupt
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at engine/ccr/store_sqlite.go:293 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/9bf921d80ad5f3e2. Report an issue: GitHub.

Appendix: source

Thrown at engine/ccr/store_sqlite.go:293

	}
	if err != nil {
		return err
	}
	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

View on GitHub (pinned to 766dce6b13)