From 6c37ec939c25dffaadea84f160d497679367e7ee Mon Sep 17 00:00:00 2001 From: bxiiiiii <1551097460@qq.com> Date: Sat, 30 Jul 2022 20:11:58 +0800 Subject: [PATCH 1/2] fix: GetNextId in ZK component throw zk: node does not exist --- components/sequencer/zookeeper/zookeeper_sequencer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/sequencer/zookeeper/zookeeper_sequencer.go b/components/sequencer/zookeeper/zookeeper_sequencer.go index 2291330235..8c77a9bbae 100644 --- a/components/sequencer/zookeeper/zookeeper_sequencer.go +++ b/components/sequencer/zookeeper/zookeeper_sequencer.go @@ -95,6 +95,13 @@ func (s *ZookeeperSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequen stat, err := s.client.Set("/"+req.Key, []byte(""), -1) if err != nil { + if err == zk.ErrNoNode { + _, err1 := s.client.Create("/"+req.Key, []byte(""), zk.FlagEphemeral, zk.WorldACL(zk.PermAll)) + if err1 != nil { + return nil, err1 + } + return s.GetNextId(req) + } return nil, err } // create node version=0, every time we set node will result in version+1 From ea2266f56c896d1675ee44e5c0c7121b2c344d4e Mon Sep 17 00:00:00 2001 From: bxiiiiii <1551097460@qq.com> Date: Thu, 4 Aug 2022 21:02:55 +0800 Subject: [PATCH 2/2] rename err to errCreate --- components/sequencer/zookeeper/zookeeper_sequencer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/sequencer/zookeeper/zookeeper_sequencer.go b/components/sequencer/zookeeper/zookeeper_sequencer.go index 8c77a9bbae..7f7959d717 100644 --- a/components/sequencer/zookeeper/zookeeper_sequencer.go +++ b/components/sequencer/zookeeper/zookeeper_sequencer.go @@ -96,9 +96,9 @@ func (s *ZookeeperSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequen if err != nil { if err == zk.ErrNoNode { - _, err1 := s.client.Create("/"+req.Key, []byte(""), zk.FlagEphemeral, zk.WorldACL(zk.PermAll)) - if err1 != nil { - return nil, err1 + _, errCreate := s.client.Create("/"+req.Key, []byte(""), zk.FlagEphemeral, zk.WorldACL(zk.PermAll)) + if errCreate != nil { + return nil, errCreate } return s.GetNextId(req) }