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

Issue 2348 #2349

Closed
wants to merge 10 commits into from
Closed

Issue 2348 #2349

wants to merge 10 commits into from

Conversation

iwanghc
Copy link
Collaborator

@iwanghc iwanghc commented Apr 11, 2024

关联的 issue

#2348

描述你的变更

sqle启动插件逻辑,新增记录插件pid文件,kill残留插件进程逻辑

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc

sqle/driver/plugin_manager.go Outdated Show resolved Hide resolved
sqle/driver/plugin_manager.go Outdated Show resolved Hide resolved
sqle/driver/plugin_manager.go Outdated Show resolved Hide resolved

// 退出进程
func KillProcess(process *os.Process) error {
err := process.Signal(syscall.SIGTERM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个方式可能无法终止假死的进程,建议等待一段时间,如果还没有退出,就用kill -9兜底

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

2秒后若不能成功退出插件进程,则直接process.kill()

Copy link
Collaborator

Choose a reason for hiding this comment

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

err := process.Signal(syscall.SIGTERM) 这里如果卡住没有退出,是进不去case <-doneChan.C 这个case的,也就是2秒的定时不起作用

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

process.Signal(syscall.SIGTERM)不会卡主,这里仅是向进程发送一个退出的信号,并不等待结果,process.Wait()才会阻塞

log.NewEntry().Warnf("get plugin %s process failed, error: %v", pluginPidFilePath, err)
}
if process != nil {
err = KillProcess(process)
Copy link
Collaborator

Choose a reason for hiding this comment

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

极端情况下如果有多个插件需要kill,每个插件等待2秒,会拖慢sqle的启动速度,建议做成多个插件并发kill。参考使用waitgroup

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改用waitgroup形式

@iwanghc
Copy link
Collaborator Author

iwanghc commented Jun 6, 2024

commit信息不规范,切换分支,pr移至#2447

@iwanghc iwanghc closed this Jun 6, 2024
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.

None yet

2 participants