nektos/act · error
write back id to db: %w
Error message
write back id to db: %w
What it means
After inserting a cache record, insertCache immediately re-Updates it with bolthold.NextSequence()'s value written back into the record (so the ID field matches the bolt key). This error means the insert succeeded but the follow-up update transaction failed — leaving a half-initialized entry that lookups may not match. Same root causes as insert: lock contention, disk full, corruption.
Source
Thrown at pkg/artifactcache/handler.go:412
And("Complete").Eq(true).
SortBy("CreatedAt").Reverse()); err != nil {
if errors.Is(err, bolthold.ErrNotFound) {
continue
}
return nil, fmt.Errorf("find cache: %w", err)
}
return cache, nil
}
return nil, nil
}
func insertCache(db *bolthold.Store, cache *Cache) error {
if err := db.Insert(bolthold.NextSequence(), cache); err != nil {
return fmt.Errorf("insert cache: %w", err)
}
// write back id to db
if err := db.Update(cache.ID, cache); err != nil {
return fmt.Errorf("write back id to db: %w", err)
}
return nil
}
func (h *Handler) useCache(id uint64) {
db, err := h.openDB()
if err != nil {
return
}
defer db.Close()
cache := &Cache{}
if err := db.Get(id, cache); err != nil {
return
}
cache.UsedAt = time.Now().Unix()
_ = db.Update(cache.ID, cache)
}
View on GitHub (pinned to 4f41128141)
Solutions
- Treat the cache entry as not saved: rerun the workflow after clearing lock contention (stop duplicate act runs)
- Free disk space on the cache volume
- Delete the cache DB if a torn record makes the error repeat
- Run cache-heavy matrix jobs with fewer parallel shards
Defensive patterns
Strategy: try-catch
Try / catch
if err := insertCache(db, cache); err != nil {
if strings.Contains(err.Error(), "write back id") {
// entry partially persisted; remove it to avoid a torn record
_ = db.Delete(cache.ID, cache)
}
log.Warnf("cache save failed: %v", err)
} Prevention
- Treat insert+write-back as one logical unit; clean up on failure
- Avoid concurrent cache saves to the same store
- Clear the DB if torn records cause repeat failures
When it happens
Trigger: The two-step insert+update in insertCache (handler.go:406) racing with another writer, or hitting ENOSPC between the insert and update transactions.
Common situations: Concurrent cache saves from parallel matrix jobs through one cache server; low-disk CI runners; act crashed between the two transactions on a previous run.
Related errors
- find cache: %w
- insert cache: %w
- parse %q: %w
- broken file: %v != %v
- GoGitActionCache failed to open bare git %s with sha %s subp
AI-assisted analysis of nektos/act@4f41128141 (2026-08-15).
Data as JSON: /api/errors/7cfa29d5f5794aa9.
Report an issue: GitHub.