gogf / gf

GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
https://goframe.org
MIT License
11.68k stars 1.59k forks source link

contrib/registry/file: registry file was deleted when multiple services registered #3709

Open songjianzhong opened 3 months ago

songjianzhong commented 3 months ago

Go version

go 1.21

GoFrame version

v2.7.2

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

多个服务共用一个目录注册时,file_discovery.go第97行执行gfile.Remove(filePath),会误删其他服务的注册文件,导致服务使用异常。

What did you see happen?

当多个服务共用一个目录注册时,file_discovery.go第97行执行gfile.Remove(filePath),会误删其他服务的注册文件,导致服务使用异常。

What did you expect to see?

filediscovery.go第97行不能执行gfile.Remove(filePath)。建议将 = gfile.Remove(filePath)这行删除。

gqcn commented 1 month ago

@songjianzhong 这里不能直接删除,因为服务其实有心跳逻辑会更新文件中的更新时间,可能更新时间没有得到及时更新导致的。建议debug一下流程,看看是不是在file 没有及时更新时间。如果是可以提个一个pr来修复。

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@songjianzhong It cannot be deleted directly because the service actually has heartbeat logic to update the update time in the file. It may be that the update time is not updated in time. It is recommended to debug the process to see if file does not update the time in time. If so, you can submit a PR to fix it.

gqcn commented 1 month ago

@songjianzhong 请提供可复现该问题的最小可运行代码。

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@songjianzhong Please provide the smallest runnable code that can reproduce the problem.