rqlite/rqlite · critical
failed to retrieve last log entry at index %d: %s
Error message
failed to retrieve last log entry at index %d: %s
What it means
Symmetric to the first-entry check: rqlite reads the last Raft log entry (at index li). Failure means the newest entry referenced by the log store cannot be read, so the node cannot safely resume Raft at its last-known position; Open aborts with "failed to retrieve last log entry at index %d: %s".
Source
Thrown at store/store.go:753
return fmt.Errorf("failed to determine size of Raft log: %s", err)
}
s.boltStore, err = rlog.New(s.raftDBPath, s.NoFreeListSync)
if err != nil {
return fmt.Errorf("new log store: %s", err)
}
fi, li, err := s.boltStore.Indexes()
if err != nil {
return fmt.Errorf("failed to retrieve log store indexes: %s", err)
}
s.logger.Println(raftLogInfoMessage(raftDBSize, fi, li))
if fi != 0 && li != 0 {
err = s.boltStore.GetLog(fi, &raft.Log{})
if err != nil {
return fmt.Errorf("failed to retrieve first log entry at index %d: %s", fi, err)
}
err = s.boltStore.GetLog(li, &raft.Log{})
if err != nil {
return fmt.Errorf("failed to retrieve last log entry at index %d: %s", li, err)
}
}
s.raftStable = s.boltStore
s.raftLog, err = raft.NewLogCache(raftLogCacheSize, s.boltStore)
if err != nil {
return fmt.Errorf("new cached store: %s", err)
}
// Request to recover node?
if fsutil.PathExists(s.peersPath) {
s.logger.Printf("attempting node recovery using %s", s.peersPath)
config, err := raft.ReadConfigJSON(s.peersPath)
if err != nil {
return fmt.Errorf("failed to read peers file: %s", err.Error())
}
// Recovering a node invalidates any existing SQLite file.
if err := fsutil.RemoveFile(s.cleanSnapshotPath); err != nil {View on GitHub (pinned to 7586a4d1bd)
Solutions
- Back up the data directory, then re-provision the node: remove the data dir and rejoin via -join, or restore from backup.
- If the wrapped error is ErrLogNotFound for the last index only, a truncation repair could in theory help, but rqlite does not support it officially — rejoining is safer.
- Investigate why the tail write was torn (fsync settings, host crash logs) to prevent recurrence.
Defensive patterns
Strategy: fallback
Try / catch
if strings.Contains(err.Error(), "last log entry") {
log.Fatalf("raft log tail corrupt, rejoin node from scratch: %v", err)
} Prevention
- Avoid host hard-crashes with reliable power and fencing
- Monitor disk space to prevent truncated appends
- Keep node count >= 3 for quorum-based recovery
When it happens
Trigger: boltStore.GetLog(li, &raft.Log{}) fails with a non-zero last index — the most recently appended log entry is missing or unreadable, typically from a torn write at the log tail.
Common situations: Power loss or kernel panic mid-append left a truncated tail entry in raft.db; disk-full aborted an append partway; restored data dir missing the latest bolt pages.
Related errors
- failed to retrieve log store indexes: %s
- failed to retrieve first log entry at index %d: %s
- failed to initialize buckets: %w
- failed to get first index: %s
- failed to get last index: %s
AI-assisted analysis of rqlite/rqlite@7586a4d1bd (2026-09-03).
Data as JSON: /api/errors/a328c1e133e547f1.
Report an issue: GitHub.