{"record":{"id":"a328c1e133e547f1","repo":"rqlite/rqlite","slug":"failed-to-retrieve-last-log-entry-at-index-d-s","errorCode":null,"errorMessage":"failed to retrieve last log entry at index %d: %s","messagePattern":"failed to retrieve last log entry at index (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"store/store.go","lineNumber":753,"sourceCode":"\t\treturn fmt.Errorf(\"failed to determine size of Raft log: %s\", err)\n\t}\n\ts.boltStore, err = rlog.New(s.raftDBPath, s.NoFreeListSync)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"new log store: %s\", err)\n\t}\n\tfi, li, err := s.boltStore.Indexes()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to retrieve log store indexes: %s\", err)\n\t}\n\ts.logger.Println(raftLogInfoMessage(raftDBSize, fi, li))\n\tif fi != 0 && li != 0 {\n\t\terr = s.boltStore.GetLog(fi, &raft.Log{})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to retrieve first log entry at index %d: %s\", fi, err)\n\t\t}\n\t\terr = s.boltStore.GetLog(li, &raft.Log{})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to retrieve last log entry at index %d: %s\", li, err)\n\t\t}\n\t}\n\ts.raftStable = s.boltStore\n\ts.raftLog, err = raft.NewLogCache(raftLogCacheSize, s.boltStore)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"new cached store: %s\", err)\n\t}\n\n\t// Request to recover node?\n\tif fsutil.PathExists(s.peersPath) {\n\t\ts.logger.Printf(\"attempting node recovery using %s\", s.peersPath)\n\t\tconfig, err := raft.ReadConfigJSON(s.peersPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to read peers file: %s\", err.Error())\n\t\t}\n\n\t\t// Recovering a node invalidates any existing SQLite file.\n\t\tif err := fsutil.RemoveFile(s.cleanSnapshotPath); err != nil {","sourceCodeStart":735,"sourceCodeEnd":771,"githubUrl":"https://github.com/rqlite/rqlite/blob/7586a4d1bdbd9a5a80021664c5a863cd850adb60/store/store.go#L735-L771","documentation":"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\".","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"last log entry\") {\n    log.Fatalf(\"raft log tail corrupt, rejoin node from scratch: %v\", err)\n}","preventionTips":["Avoid host hard-crashes with reliable power and fencing","Monitor disk space to prevent truncated appends","Keep node count >= 3 for quorum-based recovery"],"tags":["raft","boltdb","corruption","startup"],"backgroundTag":"raft-log-corrupt","analyzedSha":"7586a4d1bdbd9a5a80021664c5a863cd850adb60","analyzedAt":"2026-09-03T07:03:02.260Z","contentChangedAt":"2026-09-03T07:03:02.260Z","schemaVersion":2},"datasetVersion":"2026-09-10T12:17:11.382Z"}