gastownhall/beads · error
clear repo mtime: %w
Error message
clear repo mtime: %w
What it means
ClearRepoMtimeInTx deletes the repo_mtimes row matching the expanded, absolute repo path and wraps any SQL failure with "clear repo mtime: %w". It is used to invalidate the jsonl mtime cache so the next sync re-reads the file. The error indicates the DELETE statement itself failed inside the transaction.
Source
Thrown at internal/storage/issueops/bulk_ops.go:447
VALUES (?, ?, ?, NOW())
ON DUPLICATE KEY UPDATE
jsonl_path = VALUES(jsonl_path),
mtime_ns = VALUES(mtime_ns),
last_checked = NOW()
`, repoPath, jsonlPath, mtimeNs)
if err != nil {
return fmt.Errorf("set repo mtime: %w", err)
}
return nil
}
// ClearRepoMtimeInTx removes the mtime cache entry for a repo path.
func ClearRepoMtimeInTx(ctx context.Context, tx *sql.Tx, repoPath string) error {
// Expand ~ and resolve to absolute path to match stored format.
absPath := expandAndAbsPath(repoPath)
_, err := tx.ExecContext(ctx, `DELETE FROM repo_mtimes WHERE repo_path = ?`, absPath)
if err != nil {
return fmt.Errorf("clear repo mtime: %w", err)
}
return nil
}
func expandAndAbsPath(p string) string {
if strings.HasPrefix(p, "~") {
home, err := os.UserHomeDir()
if err == nil {
if p == "~" {
p = home
} else {
p = filepath.Join(home, p[2:])
}
}
}
abs, err := filepath.Abs(p)
if err != nil {
return pView on GitHub (pinned to 71377f2769)
Solutions
- Apply pending schema migrations so repo_mtimes exists.
- Roll back and retry the whole transaction; a DELETE can fail from a poisoned transaction.
- Check the wrapped error for 'lock wait timeout' and look for competing bd processes holding locks.
- Ensure the context passed in is not already cancelled/deadlined before the cleanup call.
Defensive patterns
Strategy: try-catch
Validate before calling
if ctx.Err() != nil { return ctx.Err() } Try / catch
if err := issueops.ClearRepoMtimeInTx(ctx, tx, repoPath); err != nil {
tx.Rollback()
return fmt.Errorf("cache invalidation failed: %w", err)
} Prevention
- Roll back transactions immediately when any statement fails.
- Run migrations after upgrading bd before running sync.
- Check for concurrent bd processes before long cleanup transactions.
- Always pass the same repoPath format (absolute) used when setting the entry.
When it happens
Trigger: Calling ClearRepoMtimeInTx when: the repo_mtimes table is missing (unmigrated schema), the transaction was aborted by a prior error, the context was cancelled, or the DB connection dropped before/during the DELETE.
Common situations: Stale-schema databases after upgrading bd; callers that ignore an earlier failed statement and keep using the aborted transaction; cancellation during an import that tries to clean up cache entries; network blips to a remote Dolt server.
Related errors
- set repo mtime: %w
- failed to claim issue: %w
- get dependent records from %s: %w
- count wisp-only dependent records: %w
- count dependent records from %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/8ce1bbec275dc31f.
Report an issue: GitHub.