diff --git a/cmd/main.go b/cmd/main.go index db9d16b..7df8f39 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -31,7 +31,7 @@ func main() { port := flag.String("port", ":9091", "rpc listen port") cluster := flag.String("cluster", "127.0.0.1:9091,127.0.0.1:9092,127.0.0.1:9093", "comma sep") id := flag.String("id", "1", "node ID") - isNewDb := flag.Bool("isNewDb", true, "new test or restart") + isRestart := flag.Bool("isRestart", true, "new test or restart") // 参数解析 flag.Parse() @@ -51,11 +51,14 @@ func main() { idCnt++ } - if *isNewDb { - os.RemoveAll("leveldb/simple-kv-store" + *id) + if *isRestart { os.RemoveAll("storage/node" + *id + ".json") } - // 打开或创建每个结点自己的数据库 + + // 创建每个结点自己的数据库。这里一开始理解上有些误区,状态机的状态恢复应该靠节点的持久化log, + // 而用leveldb模拟状态机,造成了状态机本身的持久化,因此暂时通过删去旧db避免这一矛盾 + os.RemoveAll("leveldb/simple-kv-store" + *id) + db, err := leveldb.OpenFile("leveldb/simple-kv-store"+*id, nil) if err != nil { log.Fatal("Failed to open database: ", zap.Error(err)) @@ -67,14 +70,9 @@ func main() { // 打开或创建节点数据持久化文件 storage := nodes.NewRaftStorage("storage/node" + *id + ".json") - // 计数 - count := 0 - for iter.Next() { - count++ - } - log.Sugar().Infof("[%s]目前有数据:%d", *id, count) + // 初始化 + node := nodes.Init(*id, idClusterPairs, db, storage, !*isRestart) - node := nodes.Init(*id, idClusterPairs, db, storage) log.Sugar().Infof("[%s]开始监听" + *port + "端口", *id) // 监听rpc node.Rpc(*port) diff --git a/internal/nodes/init.go b/internal/nodes/init.go index 4142038..170cfe0 100644 --- a/internal/nodes/init.go +++ b/internal/nodes/init.go @@ -21,7 +21,7 @@ func newNode(address string) *Public_node_info { } } -func Init(selfId string, nodeAddr map[string]string, db *leveldb.DB, rstorage *RaftStorage) *Node { +func Init(selfId string, nodeAddr map[string]string, db *leveldb.DB, rstorage *RaftStorage, isRestart bool) *Node { ns := make(map[string]*Public_node_info) for id, addr := range nodeAddr { ns[id] = newNode(addr) @@ -43,6 +43,13 @@ func Init(selfId string, nodeAddr map[string]string, db *leveldb.DB, rstorage *R storage: rstorage, } node.initLeaderState() + if isRestart { + node.currTerm = rstorage.GetCurrentTerm() + node.votedFor = rstorage.GetVotedFor() + node.log = rstorage.GetLogEntries() + log.Sugar().Infof("[%s]从重启中恢复log数量: %d", selfId, len(node.log)) + } + return node } @@ -51,7 +58,6 @@ func (n *Node) initLeaderState() { n.nextIndex[peerId] = len(n.log) // 发送日志的下一个索引 n.matchIndex[peerId] = 0 // 复制日志的最新匹配索引 } - n.storage.SetTermAndVote(n.currTerm, n.votedFor) } func Start(node *Node) { diff --git a/internal/nodes/node_storage.go b/internal/nodes/node_storage.go index 92b5add..526607d 100644 --- a/internal/nodes/node_storage.go +++ b/internal/nodes/node_storage.go @@ -42,7 +42,7 @@ func (rs *RaftStorage) loadData() { err = json.NewDecoder(file).Decode(rs) if err != nil { - log.Error("读取文件失败:" + rs.filePath) + log.Error("读取文件失败:" + rs.filePath, zap.Error(err)) } } diff --git a/internal/nodes/vote.go b/internal/nodes/vote.go index 5b1e12a..9ad9e9d 100644 --- a/internal/nodes/vote.go +++ b/internal/nodes/vote.go @@ -106,6 +106,8 @@ func (n *Node) startElection() { select { case <-timeout: log.Sugar().Infof("[%s] 选举超时,重新发起选举", n.selfId) + n.state = Follower + n.resetElectionTimer() mu.Unlock() return default: diff --git a/test/common.go b/test/common.go index 65c5929..3b0dc35 100644 --- a/test/common.go +++ b/test/common.go @@ -8,21 +8,21 @@ import ( "strings" ) -func ExecuteNodeI(i int, isNewDb bool, clusters []string) *exec.Cmd { +func ExecuteNodeI(i int, isRestart bool, clusters []string) *exec.Cmd { port := fmt.Sprintf(":%d", uint16(9090)+uint16(i)) - var isnewdb string - if isNewDb { - isnewdb = "true" + var isRestartStr string + if isRestart { + isRestartStr = "true" } else { - isnewdb = "false" + isRestartStr = "false" } cmd := exec.Command( "../main", "-id", strconv.Itoa(i + 1), "-port", port, "-cluster", strings.Join(clusters, ","), - "-isNewDb=" + isnewdb, + "-isRestart=" + isRestartStr, ) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr diff --git a/test/test.log b/test/test.log new file mode 100644 index 0000000..7497e12 --- /dev/null +++ b/test/test.log @@ -0,0 +1,1486 @@ +=== RUN TestNodeRestart +{"level":"info","ts":"2025-03-19T16:33:04.732882+0800","caller":"nodes/node_storage.go:37","msg":"文件未创建:storage/node1.json"} +{"level":"info","ts":"2025-03-19T16:33:04.732984+0800","caller":"cmd/main.go:76","msg":"[1]开始监听:9090端口"} +[1] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:04.73446+0800","caller":"nodes/node_storage.go:37","msg":"文件未创建:storage/node2.json"} +{"level":"info","ts":"2025-03-19T16:33:04.734461+0800","caller":"nodes/node_storage.go:37","msg":"文件未创建:storage/node3.json"} +{"level":"info","ts":"2025-03-19T16:33:04.734473+0800","caller":"nodes/node_storage.go:37","msg":"文件未创建:storage/node5.json"} +{"level":"info","ts":"2025-03-19T16:33:04.734518+0800","caller":"cmd/main.go:76","msg":"[2]开始监听:9091端口"} +{"level":"info","ts":"2025-03-19T16:33:04.734523+0800","caller":"cmd/main.go:76","msg":"[3]开始监听:9092端口"} +{"level":"info","ts":"2025-03-19T16:33:04.734541+0800","caller":"cmd/main.go:76","msg":"[5]开始监听:9094端口"} +{"level":"info","ts":"2025-03-19T16:33:04.7345+0800","caller":"nodes/node_storage.go:37","msg":"文件未创建:storage/node4.json"} +{"level":"info","ts":"2025-03-19T16:33:04.734637+0800","caller":"cmd/main.go:76","msg":"[4]开始监听:9093端口"} +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:05.252194+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 2"} +{"level":"info","ts":"2025-03-19T16:33:05.252391+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:05.25245+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:05.252485+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:05.252595+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:05.253214+0800","caller":"nodes/vote.go:178","msg":"在term(2), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:05.253216+0800","caller":"nodes/vote.go:178","msg":"在term(2), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:05.253222+0800","caller":"nodes/vote.go:178","msg":"在term(2), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:05.253544+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +{"level":"info","ts":"2025-03-19T16:33:05.253604+0800","caller":"nodes/vote.go:178","msg":"在term(2), [4]投票给[3]"} +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:07.349235+0800","caller":"client/client_node.go:53","msg":"client write request key :0"} +{"level":"info","ts":"2025-03-19T16:33:07.350139+0800","caller":"nodes/server_node.go:18","msg":"[1]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.350183+0800","caller":"nodes/server_node.go:28","msg":"[1]转交给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.351188+0800","caller":"nodes/server_node.go:18","msg":"[3]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.3513+0800","caller":"nodes/server_node.go:38","msg":"leader[3]处理请求 : key: 0, value: hello, 模拟方式 : 1"} +{"level":"info","ts":"2025-03-19T16:33:07.351639+0800","caller":"client/client_node.go:53","msg":"client write request key :1"} +{"level":"info","ts":"2025-03-19T16:33:07.351887+0800","caller":"nodes/replica.go:185","msg":"[5]写入:logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.352188+0800","caller":"nodes/server_node.go:18","msg":"[1]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.352211+0800","caller":"nodes/server_node.go:28","msg":"[1]转交给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.352616+0800","caller":"nodes/server_node.go:18","msg":"[3]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.35269+0800","caller":"nodes/server_node.go:38","msg":"leader[3]处理请求 : key: 1, value: hello, 模拟方式 : 1"} +{"level":"info","ts":"2025-03-19T16:33:07.352847+0800","caller":"nodes/replica.go:185","msg":"[2]写入:logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.3529+0800","caller":"client/client_node.go:53","msg":"client write request key :2"} +{"level":"info","ts":"2025-03-19T16:33:07.353179+0800","caller":"nodes/replica.go:124","msg":"Leader[3]更新 commitIndex: 0"} +{"level":"info","ts":"2025-03-19T16:33:07.35324+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.353344+0800","caller":"nodes/server_node.go:18","msg":"[1]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.353361+0800","caller":"nodes/server_node.go:28","msg":"[1]转交给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.353459+0800","caller":"nodes/replica.go:185","msg":"[1]写入:logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.353469+0800","caller":"nodes/replica.go:185","msg":"[1]写入:logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.353641+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.353708+0800","caller":"nodes/server_node.go:18","msg":"[3]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.353765+0800","caller":"nodes/replica.go:124","msg":"Leader[3]更新 commitIndex: 1"} +{"level":"info","ts":"2025-03-19T16:33:07.353773+0800","caller":"nodes/server_node.go:38","msg":"leader[3]处理请求 : key: 2, value: hello, 模拟方式 : 1"} +{"level":"info","ts":"2025-03-19T16:33:07.35378+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.353902+0800","caller":"client/client_node.go:53","msg":"client write request key :3"} +{"level":"info","ts":"2025-03-19T16:33:07.353961+0800","caller":"nodes/replica.go:185","msg":"[4]写入:logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.354005+0800","caller":"nodes/replica.go:185","msg":"[4]写入:logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.354015+0800","caller":"nodes/replica.go:185","msg":"[4]写入:logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.354201+0800","caller":"nodes/server_node.go:18","msg":"[1]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.35422+0800","caller":"nodes/server_node.go:28","msg":"[1]转交给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.354484+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.354936+0800","caller":"nodes/server_node.go:18","msg":"[3]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.355018+0800","caller":"nodes/server_node.go:38","msg":"leader[3]处理请求 : key: 3, value: hello, 模拟方式 : 1"} +{"level":"info","ts":"2025-03-19T16:33:07.355147+0800","caller":"client/client_node.go:53","msg":"client write request key :4"} +{"level":"info","ts":"2025-03-19T16:33:07.355462+0800","caller":"nodes/server_node.go:18","msg":"[1]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.35548+0800","caller":"nodes/server_node.go:28","msg":"[1]转交给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.355856+0800","caller":"nodes/server_node.go:18","msg":"[3]收到客户端write请求"} +{"level":"info","ts":"2025-03-19T16:33:07.355927+0800","caller":"nodes/server_node.go:38","msg":"leader[3]处理请求 : key: 4, value: hello, 模拟方式 : 1"} +{"level":"info","ts":"2025-03-19T16:33:07.356037+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.35623+0800","caller":"nodes/replica.go:124","msg":"Leader[3]更新 commitIndex: 2"} +{"level":"info","ts":"2025-03-19T16:33:07.356265+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.356689+0800","caller":"nodes/replica.go:185","msg":"[1]写入:logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.356697+0800","caller":"nodes/replica.go:185","msg":"[1]写入:logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.3567+0800","caller":"nodes/replica.go:185","msg":"[1]写入:logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.356854+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.356874+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.356928+0800","caller":"nodes/replica.go:124","msg":"Leader[3]更新 commitIndex: 4"} +{"level":"info","ts":"2025-03-19T16:33:07.356962+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.356978+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357207+0800","caller":"nodes/replica.go:185","msg":"[5]写入:logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357217+0800","caller":"nodes/replica.go:185","msg":"[5]写入:logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.35722+0800","caller":"nodes/replica.go:185","msg":"[5]写入:logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357223+0800","caller":"nodes/replica.go:185","msg":"[5]写入:logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357351+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357497+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357518+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357522+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.357526+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.358517+0800","caller":"nodes/replica.go:185","msg":"[4]写入:logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.35854+0800","caller":"nodes/replica.go:185","msg":"[4]写入:logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.358645+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.358659+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.358668+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359184+0800","caller":"nodes/replica.go:185","msg":"[2]写入:logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359221+0800","caller":"nodes/replica.go:185","msg":"[2]写入:logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359229+0800","caller":"nodes/replica.go:185","msg":"[2]写入:logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359236+0800","caller":"nodes/replica.go:185","msg":"[2]写入:logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.35932+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359346+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359356+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359365+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.359373+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.361259+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:07.361278+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:07.775496+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 3"} +{"level":"info","ts":"2025-03-19T16:33:07.775568+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:07.77571+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:07.775757+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:07.775809+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:07.776274+0800","caller":"nodes/vote.go:178","msg":"在term(3), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.776693+0800","caller":"nodes/vote.go:178","msg":"在term(3), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.776721+0800","caller":"nodes/vote.go:178","msg":"在term(3), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.776746+0800","caller":"nodes/vote.go:178","msg":"在term(3), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:07.777157+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:08.344486+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 4"} +{"level":"info","ts":"2025-03-19T16:33:08.344559+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.344668+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.344776+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.344922+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.345514+0800","caller":"nodes/vote.go:178","msg":"在term(4), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:08.345722+0800","caller":"nodes/vote.go:178","msg":"在term(4), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:08.346044+0800","caller":"nodes/vote.go:178","msg":"在term(4), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:08.34638+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +{"level":"info","ts":"2025-03-19T16:33:08.346573+0800","caller":"nodes/vote.go:178","msg":"在term(4), [2]投票给[3]"} +node_1接收到信号: terminated +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.386845+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.437806+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.488854+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.538801+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.589706+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[5] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.63988+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.689978+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.740967+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.791956+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.842746+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:08.88813+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 5"} +{"level":"info","ts":"2025-03-19T16:33:08.888227+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.888277+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.888416+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:08.888479+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"error","ts":"2025-03-19T16:33:08.889044+0800","caller":"nodes/vote.go:124","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendRequestVote\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:124\nsimple-kv-store/internal/nodes.(*Node).startElection.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:66"} +{"level":"info","ts":"2025-03-19T16:33:08.889187+0800","caller":"nodes/vote.go:178","msg":"在term(5), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:08.889388+0800","caller":"nodes/vote.go:178","msg":"在term(5), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:08.889378+0800","caller":"nodes/vote.go:178","msg":"在term(5), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:08.890002+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.892573+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.943467+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:08.994118+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.045034+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.095924+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.146177+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.196843+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.248309+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.298611+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:09.348822+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9090: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +{"level":"info","ts":"2025-03-19T16:33:09.365198+0800","caller":"nodes/init.go:50","msg":"[1]从重启中恢复log数量: 5"} +{"level":"info","ts":"2025-03-19T16:33:09.365251+0800","caller":"cmd/main.go:76","msg":"[1]开始监听:9090端口"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:09.402141+0800","caller":"nodes/replica.go:159","msg":"[1]发现更高 term(5)"} +{"level":"info","ts":"2025-03-19T16:33:09.402532+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:09.402707+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:09.40274+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:09.402752+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:09.402764+0800","caller":"nodes/replica.go:136","msg":"[1]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:09.688957+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 6"} +{"level":"info","ts":"2025-03-19T16:33:09.689103+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:09.689164+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:09.689239+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:09.689289+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:09.690054+0800","caller":"nodes/vote.go:178","msg":"在term(6), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:09.690078+0800","caller":"nodes/vote.go:178","msg":"在term(6), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:09.690474+0800","caller":"nodes/vote.go:178","msg":"在term(6), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:09.690522+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +{"level":"info","ts":"2025-03-19T16:33:09.691602+0800","caller":"nodes/vote.go:178","msg":"在term(6), [2]投票给[3]"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +node_2接收到信号: terminated +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.364751+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.415952+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.466268+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.517201+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.567728+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:10.612263+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 7"} +{"level":"info","ts":"2025-03-19T16:33:10.61241+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:10.612479+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:10.612533+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:10.612615+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"error","ts":"2025-03-19T16:33:10.612686+0800","caller":"nodes/vote.go:124","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendRequestVote\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:124\nsimple-kv-store/internal/nodes.(*Node).startElection.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:66"} +{"level":"info","ts":"2025-03-19T16:33:10.613168+0800","caller":"nodes/vote.go:178","msg":"在term(7), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:10.613228+0800","caller":"nodes/vote.go:178","msg":"在term(7), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:10.613307+0800","caller":"nodes/vote.go:178","msg":"在term(7), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:10.613693+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.61813+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.668868+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.719876+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.770174+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.820851+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.871184+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.921686+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:10.973559+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.022744+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.073958+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.125207+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.175117+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.225786+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +{"level":"info","ts":"2025-03-19T16:33:11.230887+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 8"} +{"level":"info","ts":"2025-03-19T16:33:11.230953+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:11.231084+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:11.231119+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:11.231063+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"error","ts":"2025-03-19T16:33:11.23127+0800","caller":"nodes/vote.go:124","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendRequestVote\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:124\nsimple-kv-store/internal/nodes.(*Node).startElection.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:66"} +{"level":"info","ts":"2025-03-19T16:33:11.231815+0800","caller":"nodes/vote.go:178","msg":"在term(8), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:11.231799+0800","caller":"nodes/vote.go:178","msg":"在term(8), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:11.231932+0800","caller":"nodes/vote.go:178","msg":"在term(8), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:11.232256+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.276043+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:11.327108+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9091: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:11.374799+0800","caller":"nodes/init.go:50","msg":"[2]从重启中恢复log数量: 5"} +{"level":"info","ts":"2025-03-19T16:33:11.374877+0800","caller":"cmd/main.go:76","msg":"[2]开始监听:9091端口"} +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:11.380039+0800","caller":"nodes/replica.go:159","msg":"[2]发现更高 term(8)"} +{"level":"info","ts":"2025-03-19T16:33:11.38198+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:11.382073+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:11.38209+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:11.382101+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:11.38211+0800","caller":"nodes/replica.go:136","msg":"[2]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:12.085915+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 9"} +{"level":"info","ts":"2025-03-19T16:33:12.086015+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:12.086063+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:12.086109+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:12.086128+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:12.086749+0800","caller":"nodes/vote.go:178","msg":"在term(9), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:12.086839+0800","caller":"nodes/vote.go:178","msg":"在term(9), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:12.086864+0800","caller":"nodes/vote.go:178","msg":"在term(9), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:12.087224+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +{"level":"info","ts":"2025-03-19T16:33:12.087797+0800","caller":"nodes/vote.go:178","msg":"在term(9), [5]投票给[3]"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is the leader, 发送心跳... +[1] is a follower, 监听中... +node_3接收到信号: terminated +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:13.154887+0800","caller":"nodes/vote.go:34","msg":"[2] 开始选举,当前任期: 10"} +{"level":"info","ts":"2025-03-19T16:33:13.15498+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.155011+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.155086+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [3] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.155128+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [5] 投票给自己"} +{"level":"error","ts":"2025-03-19T16:33:13.155281+0800","caller":"nodes/vote.go:124","msg":"dialing: ","error":"dial tcp 127.0.0.1:9092: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendRequestVote\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:124\nsimple-kv-store/internal/nodes.(*Node).startElection.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:66"} +{"level":"info","ts":"2025-03-19T16:33:13.155963+0800","caller":"nodes/vote.go:178","msg":"在term(10), [4]投票给[2]"} +{"level":"info","ts":"2025-03-19T16:33:13.155967+0800","caller":"nodes/vote.go:178","msg":"在term(10), [5]投票给[2]"} +{"level":"info","ts":"2025-03-19T16:33:13.156332+0800","caller":"nodes/vote.go:178","msg":"在term(10), [1]投票给[2]"} +{"level":"info","ts":"2025-03-19T16:33:13.156484+0800","caller":"nodes/vote.go:87","msg":"[2] 当选 Leader!"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:13.194293+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9092: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:13.244458+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9092: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:13.29539+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9092: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:13.346101+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9092: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[1] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:13.370791+0800","caller":"nodes/init.go:50","msg":"[3]从重启中恢复log数量: 5"} +{"level":"info","ts":"2025-03-19T16:33:13.370831+0800","caller":"cmd/main.go:76","msg":"[3]开始监听:9092端口"} +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:13.398345+0800","caller":"nodes/replica.go:159","msg":"[3]发现更高 term(10)"} +{"level":"info","ts":"2025-03-19T16:33:13.399202+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:13.399249+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:13.399261+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:13.39927+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:13.399274+0800","caller":"nodes/replica.go:136","msg":"[3]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:13.875905+0800","caller":"nodes/vote.go:34","msg":"[2] 开始选举,当前任期: 11"} +{"level":"info","ts":"2025-03-19T16:33:13.875978+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.876039+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.876072+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.876109+0800","caller":"nodes/vote.go:121","msg":"[2] 请求 [3] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:13.876582+0800","caller":"nodes/vote.go:178","msg":"在term(11), [5]投票给[2]"} +{"level":"info","ts":"2025-03-19T16:33:13.876672+0800","caller":"nodes/vote.go:178","msg":"在term(11), [1]投票给[2]"} +{"level":"info","ts":"2025-03-19T16:33:13.87692+0800","caller":"nodes/vote.go:178","msg":"在term(11), [3]投票给[2]"} +{"level":"info","ts":"2025-03-19T16:33:13.876966+0800","caller":"nodes/vote.go:87","msg":"[2] 当选 Leader!"} +{"level":"info","ts":"2025-03-19T16:33:13.877705+0800","caller":"nodes/vote.go:178","msg":"在term(11), [4]投票给[2]"} +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[4] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is the leader, 发送心跳... +[1] is a follower, 监听中... +[3] is a follower, 监听中... +[5] is a follower, 监听中... +[4] is a follower, 监听中... +[2] is the leader, 发送心跳... +node_4接收到信号: terminated +{"level":"error","ts":"2025-03-19T16:33:14.362525+0800","caller":"nodes/replica.go:87","msg":"dialing node_4fail: ","error":"read tcp 127.0.0.1:57820->127.0.0.1:9093: read: connection reset by peer","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:87\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +{"level":"info","ts":"2025-03-19T16:33:14.362591+0800","caller":"nodes/replica.go:91","msg":"Leader[2]收到更高的 term=0,转换为 Follower"} +{"level":"info","ts":"2025-03-19T16:33:14.363163+0800","caller":"nodes/replica.go:91","msg":"Leader[2]收到更高的 term=11,转换为 Follower"} +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[3] is a follower, 监听中... +[1] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:14.841961+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 12"} +{"level":"info","ts":"2025-03-19T16:33:14.842091+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:14.842143+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:14.842205+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:14.842371+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"error","ts":"2025-03-19T16:33:14.842823+0800","caller":"nodes/vote.go:124","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendRequestVote\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:124\nsimple-kv-store/internal/nodes.(*Node).startElection.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:66"} +{"level":"info","ts":"2025-03-19T16:33:14.843101+0800","caller":"nodes/vote.go:178","msg":"在term(12), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:14.843142+0800","caller":"nodes/vote.go:178","msg":"在term(12), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:14.843561+0800","caller":"nodes/vote.go:178","msg":"在term(12), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:14.843603+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:14.884912+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:14.935885+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:14.987044+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.038088+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.088359+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.13871+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.189056+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.240204+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.290817+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:15.342033+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9093: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:15.37582+0800","caller":"nodes/init.go:50","msg":"[4]从重启中恢复log数量: 5"} +{"level":"info","ts":"2025-03-19T16:33:15.375881+0800","caller":"cmd/main.go:76","msg":"[4]开始监听:9093端口"} +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:15.395721+0800","caller":"nodes/replica.go:159","msg":"[4]发现更高 term(12)"} +{"level":"info","ts":"2025-03-19T16:33:15.397762+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:15.397812+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:15.397826+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:15.397835+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:15.397845+0800","caller":"nodes/replica.go:136","msg":"[4]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:15.43107+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 13"} +{"level":"info","ts":"2025-03-19T16:33:15.431188+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:15.431354+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:15.431404+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:15.431436+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:15.432183+0800","caller":"nodes/vote.go:178","msg":"在term(13), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:15.43217+0800","caller":"nodes/vote.go:178","msg":"在term(13), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:15.432282+0800","caller":"nodes/vote.go:178","msg":"在term(13), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:15.432316+0800","caller":"nodes/vote.go:178","msg":"在term(13), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:15.432667+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:16.32575+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 14"} +{"level":"info","ts":"2025-03-19T16:33:16.325829+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:16.325886+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:16.325942+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:16.325907+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:16.326398+0800","caller":"nodes/vote.go:178","msg":"在term(14), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:16.326409+0800","caller":"nodes/vote.go:178","msg":"在term(14), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:16.326424+0800","caller":"nodes/vote.go:178","msg":"在term(14), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:16.326443+0800","caller":"nodes/vote.go:178","msg":"在term(14), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:16.326712+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +node_5接收到信号: terminated +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.404914+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.4558+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.506823+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.557304+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.6079+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.659135+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.710166+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.760322+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.810944+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.861248+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.911344+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:16.961478+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.012026+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.062225+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.112638+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.163187+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:17.200007+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 15"} +{"level":"info","ts":"2025-03-19T16:33:17.200092+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.200178+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.200296+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.200421+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"error","ts":"2025-03-19T16:33:17.200627+0800","caller":"nodes/vote.go:124","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendRequestVote\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:124\nsimple-kv-store/internal/nodes.(*Node).startElection.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/vote.go:66"} +{"level":"info","ts":"2025-03-19T16:33:17.201245+0800","caller":"nodes/vote.go:178","msg":"在term(15), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.201319+0800","caller":"nodes/vote.go:178","msg":"在term(15), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.20138+0800","caller":"nodes/vote.go:178","msg":"在term(15), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.201735+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.21428+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.265118+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.315339+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"error","ts":"2025-03-19T16:33:17.365734+0800","caller":"nodes/replica.go:52","msg":"dialing: ","error":"dial tcp 127.0.0.1:9094: connect: connection refused","stacktrace":"simple-kv-store/internal/nodes.(*Node).sendKV\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:52\nsimple-kv-store/internal/nodes.(*Node).BroadCastKV.func1\n\t/home/ld/go-codes/go-work-place/simple-kv-store/internal/nodes/replica.go:32"} +{"level":"info","ts":"2025-03-19T16:33:17.377533+0800","caller":"nodes/init.go:50","msg":"[5]从重启中恢复log数量: 5"} +{"level":"info","ts":"2025-03-19T16:33:17.377618+0800","caller":"cmd/main.go:76","msg":"[5]开始监听:9094端口"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +{"level":"info","ts":"2025-03-19T16:33:17.417447+0800","caller":"nodes/replica.go:159","msg":"[5]发现更高 term(15)"} +{"level":"info","ts":"2025-03-19T16:33:17.418764+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 0, term: 2, key: 0, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:17.419002+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 1, term: 2, key: 1, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:17.419067+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 2, term: 2, key: 2, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:17.419091+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 3, term: 2, key: 3, value: hello"} +{"level":"info","ts":"2025-03-19T16:33:17.419112+0800","caller":"nodes/replica.go:136","msg":"[5]应用日志到状态机: logid: 4, term: 2, key: 4, value: hello"} +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:17.844031+0800","caller":"nodes/vote.go:34","msg":"[3] 开始选举,当前任期: 16"} +{"level":"info","ts":"2025-03-19T16:33:17.844114+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [5] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.84418+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [2] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.844242+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [4] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.844276+0800","caller":"nodes/vote.go:121","msg":"[3] 请求 [1] 投票给自己"} +{"level":"info","ts":"2025-03-19T16:33:17.844925+0800","caller":"nodes/vote.go:178","msg":"在term(16), [2]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.844956+0800","caller":"nodes/vote.go:178","msg":"在term(16), [1]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.844956+0800","caller":"nodes/vote.go:178","msg":"在term(16), [5]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.845215+0800","caller":"nodes/vote.go:178","msg":"在term(16), [4]投票给[3]"} +{"level":"info","ts":"2025-03-19T16:33:17.845776+0800","caller":"nodes/vote.go:87","msg":"[3] 当选 Leader!"} +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +[1] is a follower, 监听中... +[3] is the leader, 发送心跳... +[5] is a follower, 监听中... +[2] is a follower, 监听中... +[4] is a follower, 监听中... +{"level":"info","ts":"2025-03-19T16:33:18.363711+0800","caller":"client/client_node.go:86","msg":"client read request key :0"} +{"level":"info","ts":"2025-03-19T16:33:18.364152+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.364311+0800","caller":"client/client_node.go:86","msg":"client read request key :1"} +{"level":"info","ts":"2025-03-19T16:33:18.364527+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.364673+0800","caller":"client/client_node.go:86","msg":"client read request key :2"} +{"level":"info","ts":"2025-03-19T16:33:18.3649+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.365006+0800","caller":"client/client_node.go:86","msg":"client read request key :3"} +{"level":"info","ts":"2025-03-19T16:33:18.365194+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.365297+0800","caller":"client/client_node.go:86","msg":"client read request key :4"} +{"level":"info","ts":"2025-03-19T16:33:18.365497+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.36564+0800","caller":"client/client_node.go:86","msg":"client read request key :5"} +{"level":"info","ts":"2025-03-19T16:33:18.365875+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.365996+0800","caller":"client/client_node.go:86","msg":"client read request key :6"} +{"level":"info","ts":"2025-03-19T16:33:18.366253+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.366379+0800","caller":"client/client_node.go:86","msg":"client read request key :7"} +{"level":"info","ts":"2025-03-19T16:33:18.366604+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.366735+0800","caller":"client/client_node.go:86","msg":"client read request key :8"} +{"level":"info","ts":"2025-03-19T16:33:18.366947+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.367088+0800","caller":"client/client_node.go:86","msg":"client read request key :9"} +{"level":"info","ts":"2025-03-19T16:33:18.367311+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.36762+0800","caller":"client/client_node.go:86","msg":"client read request key :10"} +{"level":"info","ts":"2025-03-19T16:33:18.367871+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.367998+0800","caller":"client/client_node.go:86","msg":"client read request key :11"} +{"level":"info","ts":"2025-03-19T16:33:18.368232+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.368366+0800","caller":"client/client_node.go:86","msg":"client read request key :12"} +{"level":"info","ts":"2025-03-19T16:33:18.368614+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.368752+0800","caller":"client/client_node.go:86","msg":"client read request key :13"} +{"level":"info","ts":"2025-03-19T16:33:18.368966+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +{"level":"info","ts":"2025-03-19T16:33:18.369078+0800","caller":"client/client_node.go:86","msg":"client read request key :14"} +{"level":"info","ts":"2025-03-19T16:33:18.36934+0800","caller":"nodes/server_node.go:47","msg":"[1]收到客户端read请求"} +--- PASS: TestNodeRestart (12.02s) +PASS +node_1接收到信号: terminated +node_2接收到信号: terminated +node_4接收到信号: terminated +node_3接收到信号: terminated +node_5接收到信号: terminated +ok simple-kv-store/test 12.025s