rqlite/rqlite · error

failed to get last modified time: %s

Error message

failed to get last modified time: %s

What it means

Wraps a failure from s.db.DBLastModified() at the tail of the restore. The node records the installed database's modification time so it can serve fast restarts and staleness checks; if SQLite cannot report the last-modified time of the newly installed DB, the restore fails at this final step.

Source

Thrown at store/store.go:2849

	if err != nil {
		return fmt.Errorf("failed to get latest snapshot index post restore: %s", err)
	}

	// Installed SQLite database is safe for fast restarts again. It is fingerprinted
	// against the very index and term the node is adopting here, so that a restart
	// can tell that the two still correspond to one another.
	if err := s.createSnapshotFingerprint(li, tm); err != nil {
		return fmt.Errorf("failed to create snapshot fingerprint post restore: %s", err)
	}

	s.fsmIdx.Store(li)
	s.fsmTarget.Signal(li)
	s.fsmTerm.Store(tm)
	s.dbAppliedIdx.Store(li)
	s.appliedTarget.Signal(li)
	lt, err := s.db.DBLastModified()
	if err != nil {
		return fmt.Errorf("failed to get last modified time: %s", err)
	}
	s.dbModifiedTime.Store(lt)
	// Swapping in a new database deactivates the CDC hooks, so signal that it
	// needs to be reregistered on the next commit.
	s.cdcRegistered.Unset()

	stats.Add(numRestores, 1)
	s.logger.Printf("node restored in %s", time.Since(startT))
	return nil
}

// ForceSnapshotRestore forces the Store to restore its state from the Snapshot
// Store on startup. Store must be closed before calling. Mostly useful for testing.
func (s *Store) ForceSnapshotRestore() error {
	if s.open.Is() {
		return ErrOpen
	}

View on GitHub (pinned to 7586a4d1bd)

Solutions

  1. Check that the expected SQLite file exists and is readable in the data directory (ls -l)
  2. Retry the restore/boot once the filesystem is healthy
  3. Avoid network filesystems for the data directory; use local disk
  4. Check logs for the preceding 'error swapping database file' that may have left state inconsistent
  5. Restart the node and let it rejoin/re-restore from the leader

Example fix

// before: DB file on flaky NFS mount
$ df -T /var/rqlite/data  # nfs
// after
$ mv /var/rqlite/data /var/rqlite/data.local && ln -s local ... # or reconfigure datadir to local disk
Defensive patterns

Strategy: validation

Validate before calling

# verify the DB file exists and is stat-able right after swap
$ sudo -u rqlite stat /var/rqlite/data/db.sqlite

Prevention

When it happens

Trigger: Right after swapping in the restored database, the query for the DB file's last-modified time fails — the installed file is missing/unreadable post-swap, the DB handle is in a bad state, or the underlying filesystem stat fails (network filesystem, I/O error).

Common situations: The swap step half-completed leaving no readable database file; NFS/network storage hiding the just-swapped file; filesystem I/O errors; race where external tooling moved the database file.

Related errors


AI-assisted analysis of rqlite/rqlite@7586a4d1bd (2026-09-03). Data as JSON: /api/errors/bf9a2ebc169ff288. Report an issue: GitHub.