Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#717·raft

panic: failed to save current term: database not open when closing the store

Author: gruyaumeCreated Sep 22, 2026Updated Sep 22, 2026

Summary

Raft can panic if a heartbeat from a leader arrives during the shutdown sequence. This causes flakiness in Ella Core, which depends on raft.

We call Raft.Shutdown(), wait on future.Error(), and then close our BoltDB log/stable store. A heartbeat still executing on a transport goroutine reaches the store after it has closed.

Environment

  • Version: hashicorp/raft v1.8.0
  • Transport: NetworkTransport. Store: raft-boltdb/v2

Logs

panic: failed to save current term: database not open

github.com/hashicorp/raft.(*Raft).setCurrentTerm(...)
    [email protected]/raft.go:2167
github.com/hashicorp/raft.(*Raft).appendEntries(...)
    [email protected]/raft.go:1483
github.com/hashicorp/raft.(*Raft).processHeartbeat(...)
    [email protected]/raft.go:1449
github.com/hashicorp/raft.(*NetworkTransport).handleCommand(...)
    [email protected]/net_transport.go:727
github.com/hashicorp/raft.(*NetworkTransport).handleConn(...)
    [email protected]/net_transport.go:622

Reproducing

Widen the window in processHeartbeat (raft.go:1447):

go
 	switch cmd := rpc.Command.(type) {
 	case *AppendEntriesRequest:
+		time.Sleep(500 * time.Millisecond)
 		r.appendEntries(rpc, cmd)

Then, with a live leader still heartbeating the node: Shutdown() it, wait on future.Error(), and close its BoltStore.

Source: hashicorp/raft

View original on GitHubView discussion on GitHub