Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/registry/zookeeper: 服务多实例,会删除之前的注册信息 #4149

Open
fengpengyun opened this issue Feb 11, 2025 · 0 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@fengpengyun
Copy link

fengpengyun commented Feb 11, 2025

Go version

go version go1.23.4 windows/amd64

GoFrame version

2.8.3

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

``
gsvc.SetRegistry(zookeeper.New(
[]string{"127.0.0.1:2181"}, zookeeper.WithRootPath("/gogf"),
))

		s := g.Server("hello.svc")

		s.BindHandler("/", func(r *ghttp.Request) {
			g.Log().Info(r.Context(), `request received`)
			r.Response.Write(`Hello world`)
		})

		s.Run()

`

What did you see happen?

zookeeper_register.go
``
// ensureName ensure node exists, if not exist, create and set data
func (r *Registry) ensureName(path string, data []byte, flags int32) error {
exists, stat, err := r.conn.Exists(path)
if err != nil {
return gerror.Wrapf(err,
"Error with check node exist which name is %s",
path,
)
}
// ephemeral nodes handling after restart
// fixes a race condition if the server crashes without using CreateProtectedEphemeralSequential()
if flags&zk.FlagEphemeral == zk.FlagEphemeral {
// 此处会删除 原有server name对应的node节点
err = r.conn.Delete(path, stat.Version)
if err != nil && err != zk.ErrNoNode {
return gerror.Wrapf(err,
"Error with delete node which name is %s",
path,
)
}
exists = false
}
if !exists {
if len(r.opts.user) > 0 && len(r.opts.password) > 0 {
_, err = r.conn.Create(path, data, flags, zk.DigestACL(zk.PermAll, r.opts.user, r.opts.password))
} else {
_, err = r.conn.Create(path, data, flags, zk.WorldACL(zk.PermAll))
}
if err != nil {
return gerror.Wrapf(err,
"Error with create node which name is %s",
path,
)
}
}
return nil
}
`

What did you expect to see?

保留原有的server name node节点,endpoints对应添加

@fengpengyun fengpengyun added the bug It is confirmed a bug, but don't worry, we'll handle it. label Feb 11, 2025
@Issues-translate-bot Issues-translate-bot changed the title contrib/registry/zookeeper: 服务多实例,会删除之前的注册信息 contrib/registry/zookeeper: Service multiple instances will delete the previous registration information Feb 11, 2025
@fengpengyun fengpengyun changed the title contrib/registry/zookeeper: Service multiple instances will delete the previous registration information contrib/registry/zookeeper: 服务多实例,会删除之前的注册信息 Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

1 participant