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

bugfix: add restart empty sd protection #1494

Merged
merged 9 commits into from
Dec 2, 2024
Merged

Conversation

Wanghb1
Copy link

@Wanghb1 Wanghb1 commented Dec 1, 2024

The SDK switches back to the service center which has recovered from the crash as soon as the sc server starts, even though the service center has not synced data from the peer yet, which results in an interruption of service discovery.

add ut

Wanghb1 and others added 7 commits December 1, 2024 23:35
 The SDK switches back to the service center recovering from the crash as soon as the server starts, even though the service center has not synced data from the peer yet, which results in an interruption of service discovery.

add ut
)

func Init() {
enableInstanceNullProtect = config.GetBool("instance_null_protect.enable", true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认是关,因为这个功能会影响调试,可能造成开源开发者的困扰。


func Init() {
enableInstanceNullProtect = config.GetBool("instance_null_protect.enable", true)
restartProtectInterval = time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 120)) * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

输入参数校验,有效值1-120秒,默认120秒,如果参数非法则打日志提示,并设置为120秒。

restartProtectInterval = time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 120)) * time.Second
RestartProtectHttpCode = config.GetInt("instance_null_protect.http_status", 304)
logDir := filepath.Dir(config.GetString("log.file", "", config.WithStandby("logfile")))
firstLaunchFlagPath = filepath.Join(logDir, "first_launch.flag")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日志打印关键参数

)

/**
for restart service center, set a 2-minute time window to return http status 304 on discovery apis,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释错误,不要固化参数值

@@ -167,6 +168,10 @@ func (s *InstanceResource) FindInstances(w http.ResponseWriter, r *http.Request)
w.WriteHeader(http.StatusNotModified)
return
}
if len(resp.Instances) == 0 && rest.IsWithinRestartProtection() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保护逻辑,放在service/disco目录下


func Init() {
enableInstanceNullProtect = config.GetBool("instance_null_protect.enable", false)
restartProtectInterval = time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 120)) * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable为false的时候,直接退出,不用做初始化的操作了

@Wanghb1 Wanghb1 changed the title bugfix: bugfix: add restart empty sd protection Dec 2, 2024
@humingcheng humingcheng merged commit 215f4b5 into apache:dev Dec 2, 2024
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants