Skip to content

Commit

Permalink
fix: GetNextId in ZK component throw zk: node does not exist (#752)
Browse files Browse the repository at this point in the history
Co-authored-by: seeflood <[email protected]>
  • Loading branch information
bxiiiiii and seeflood authored Aug 5, 2022
1 parent a2e543c commit 3fc2919
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/sequencer/zookeeper/zookeeper_sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
_, errCreate := s.client.Create("/"+req.Key, []byte(""), zk.FlagEphemeral, zk.WorldACL(zk.PermAll))
if errCreate != nil {
return nil, errCreate
}
return s.GetNextId(req)
}
return nil, err
}
// create node version=0, every time we set node will result in version+1
Expand Down

0 comments on commit 3fc2919

Please sign in to comment.