From e86202ca9b52388b1f8b93c9faf179cc982b2399 Mon Sep 17 00:00:00 2001 From: augurier <14434658+augurier@user.noreply.gitee.com> Date: Wed, 19 Mar 2025 19:13:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=A2=E6=88=B7=E7=AB=AF?= =?UTF-8?q?=E6=89=BE=E4=B8=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/client/client_node.go | 64 +- internal/nodes/server_node.go | 21 + test/restart_node_test.go | 26 +- test/server_client_test.go | 25 +- test/test.log | 1486 ---------------------------------------- 5 files changed, 102 insertions(+), 1520 deletions(-) delete mode 100644 test/test.log diff --git a/internal/client/client_node.go b/internal/client/client_node.go index 7203518..929c601 100644 --- a/internal/client/client_node.go +++ b/internal/client/client_node.go @@ -1,6 +1,7 @@ package clientPkg import ( + "math/rand" "net/rpc" "simple-kv-store/internal/logprovider" "simple-kv-store/internal/nodes" @@ -12,7 +13,7 @@ var log, _ = logprovider.CreateDefaultZapLogger(zap.InfoLevel) type Client struct { // 连接的server端节点群 - Address [] string + Address map[string]string } type Status = uint8 @@ -23,23 +24,31 @@ const ( Fail ) +func getRandomAddress(addressMap map[string]string) string { + keys := make([]string, 0, len(addressMap)) + + // 获取所有 key + for key := range addressMap { + keys = append(keys, key) + } + + // 随机选一个 key + randomKey := keys[rand.Intn(len(keys))] + return addressMap[randomKey] +} + func (client *Client) FindActiveNode() *rpc.Client { var err error var c *rpc.Client - i := 0 - for { // 直到找到一个可连接的节点(保证至少一个节点活着) - c, err = rpc.DialHTTP("tcp", client.Address[i]) + for { // 直到找到一个可连接的节点(保证至少一个节点活着) + addr := getRandomAddress(client.Address) + c, err = rpc.DialHTTP("tcp", addr) if err != nil { log.Error("dialing: ", zap.Error(err)) - i++ } else { - break - } - if i == len(client.Address) { - log.Fatal("没找到存活节点") + return c } } - return c } func (client *Client) CloseRpcClient(c *rpc.Client) { @@ -48,7 +57,7 @@ func (client *Client) CloseRpcClient(c *rpc.Client) { log.Error("client close err: ", zap.Error(err)) } } -// + func (client *Client) Write(kvCall nodes.LogEntryCall) Status { log.Info("client write request key :" + kvCall.LogE.Key) @@ -108,8 +117,39 @@ func (client *Client) Read(key string, value *string) Status { // 查不到value client.CloseRpcClient(c) return NotFound } + } +} + +func (client *Client) FindLeader() string { + var arg struct{} + var reply nodes.FindLeaderReply + reply.Isleader = false + c := client.FindActiveNode() + var err error + + for !reply.Isleader { // 根据存活节点的反馈,直到找到leader + callErr := c.Call("Node.FindLeader", &arg, &reply) // RPC + if callErr != nil { // dial和call之间可能崩溃,重新找存活节点 + log.Error("dialing: ", zap.Error(callErr)) + client.CloseRpcClient(c) + c = client.FindActiveNode() + continue + } + + if !reply.Isleader { // 对方不是leader,根据反馈找leader + addr := client.Address[reply.LeaderId] + client.CloseRpcClient(c) + c, err = rpc.DialHTTP("tcp", addr) + for err != nil { // 重新找下一个存活节点 + c = client.FindActiveNode() + } + } else { // 成功 + client.CloseRpcClient(c) + return reply.LeaderId + } } - + log.Fatal("客户端会一直找存活节点,不会运行到这里") + return "fault" } diff --git a/internal/nodes/server_node.go b/internal/nodes/server_node.go index 7ccfc7a..a666ca9 100644 --- a/internal/nodes/server_node.go +++ b/internal/nodes/server_node.go @@ -57,3 +57,24 @@ func (node *Node) ReadKey(key string, reply *ServerReply) error { return nil } +// RPC call 测试中寻找当前leader +type FindLeaderReply struct{ + Isleader bool + LeaderId string +} +func (node *Node) FindLeader(_ struct{}, reply *FindLeaderReply) error { + // 自己不是leader,转交leader地址回复 + if node.state != Leader { + reply.Isleader = false + if (node.leaderId == "") { + log.Fatal("还没选出第一个leader") + return nil + } + reply.LeaderId = node.leaderId + return nil + } + + reply.LeaderId = node.selfId + reply.Isleader = true + return nil +} diff --git a/test/restart_node_test.go b/test/restart_node_test.go index db0c600..a82f465 100644 --- a/test/restart_node_test.go +++ b/test/restart_node_test.go @@ -15,10 +15,12 @@ func TestNodeRestart(t *testing.T) { // 登记结点信息 n := 5 var clusters []string + addressMap := make(map[string]string) for i := 0; i < n; i++ { port := fmt.Sprintf("%d", uint16(9090)+uint16(i)) addr := "127.0.0.1:" + port clusters = append(clusters, addr) + addressMap[strconv.Itoa(i + 1)] = addr } // 结点启动 @@ -28,9 +30,20 @@ func TestNodeRestart(t *testing.T) { cmds = append(cmds, cmd) } + // 通知所有进程结束 + defer func(){ + for _, cmd := range cmds { + err := cmd.Process.Signal(syscall.SIGTERM) + if err != nil { + fmt.Println("Error sending signal:", err) + return + } + } + }() + time.Sleep(time.Second) // 等待启动完毕 // client启动, 连接任意节点 - cWrite := clientPkg.Client{Address: clusters} + cWrite := clientPkg.Client{Address: addressMap} // 写入 var s clientPkg.Status @@ -65,7 +78,7 @@ func TestNodeRestart(t *testing.T) { // client启动 - cRead := clientPkg.Client{Address: clusters} + cRead := clientPkg.Client{Address: addressMap} // 读写入数据 for i := 0; i < 5; i++ { key := strconv.Itoa(i) @@ -85,13 +98,4 @@ func TestNodeRestart(t *testing.T) { t.Errorf("Read test2 fail") } } - - // 通知所有进程结束 - for _, cmd := range cmds { - err := cmd.Process.Signal(syscall.SIGTERM) - if err != nil { - fmt.Println("Error sending signal:", err) - return - } - } } diff --git a/test/server_client_test.go b/test/server_client_test.go index ff6835b..88050e8 100644 --- a/test/server_client_test.go +++ b/test/server_client_test.go @@ -15,10 +15,12 @@ func TestServerClient(t *testing.T) { // 登记结点信息 n := 5 var clusters []string + addressMap := make(map[string]string) for i := 0; i < n; i++ { port := fmt.Sprintf("%d", uint16(9090)+uint16(i)) addr := "127.0.0.1:" + port clusters = append(clusters, addr) + addressMap[strconv.Itoa(i + 1)] = addr } // 结点启动 @@ -28,9 +30,20 @@ func TestServerClient(t *testing.T) { cmds = append(cmds, cmd) } + // 通知所有进程结束 + defer func(){ + for _, cmd := range cmds { + err := cmd.Process.Signal(syscall.SIGTERM) + if err != nil { + fmt.Println("Error sending signal:", err) + return + } + } + }() + time.Sleep(time.Second) // 等待启动完毕 // client启动 - c := clientPkg.Client{Address: clusters} + c := clientPkg.Client{Address: addressMap} // 写入 var s clientPkg.Status @@ -62,14 +75,4 @@ func TestServerClient(t *testing.T) { t.Errorf("Read test2 fail") } } - - // 通知进程结束 - for _, cmd := range cmds { - err := cmd.Process.Signal(syscall.SIGTERM) - if err != nil { - fmt.Println("Error sending signal:", err) - return - } - } - } diff --git a/test/test.log b/test/test.log deleted file mode 100644 index 7497e12..0000000 --- a/test/test.log +++ /dev/null @@ -1,1486 +0,0 @@ -=== 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