-
Notifications
You must be signed in to change notification settings - Fork 2
Handle ProxySQL cleanup during sandbox deletion #48
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1245,6 +1245,13 @@ func RemoveSandbox(sandboxDir, sandbox string, runConcurrently bool) (execList [ | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // If a proxysql sub-sandbox exists, stop it before removing the directory | ||||||||||||||||||||||||||||||||
| proxysqlStop := path.Join(fullPath, "proxysql", "stop") | ||||||||||||||||||||||||||||||||
| if _, statErr := os.Stat(proxysqlStop); statErr == nil { | ||||||||||||||||||||||||||||||||
| common.CondPrintf("Stopping ProxySQL in %s\n", path.Join(fullPath, "proxysql")) | ||||||||||||||||||||||||||||||||
| _, _ = common.RunCmd(proxysqlStop) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1248
to
+1253
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| rmTargets := []string{fullPath, logDirectory} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for _, target := range rmTargets { | ||||||||||||||||||||||||||||||||
|
|
@@ -1359,6 +1366,13 @@ func RemoveCustomSandbox(sandboxDir, sandbox string, runConcurrently, useStop bo | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // If a proxysql sub-sandbox exists, stop it before removing the directory | ||||||||||||||||||||||||||||||||
| proxysqlStop := path.Join(fullPath, "proxysql", "stop") | ||||||||||||||||||||||||||||||||
| if _, statErr := os.Stat(proxysqlStop); statErr == nil { | ||||||||||||||||||||||||||||||||
| common.CondPrintf("Stopping ProxySQL in %s\n", path.Join(fullPath, "proxysql")) | ||||||||||||||||||||||||||||||||
| _, _ = common.RunCmd(proxysqlStop) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1371
to
+1373
|
||||||||||||||||||||||||||||||||
| if _, statErr := os.Stat(proxysqlStop); statErr == nil { | |
| common.CondPrintf("Stopping ProxySQL in %s\n", path.Join(fullPath, "proxysql")) | |
| _, _ = common.RunCmd(proxysqlStop) | |
| if common.ExecExists(proxysqlStop) { | |
| common.CondPrintf("Stopping ProxySQL in %s\n", path.Join(fullPath, "proxysql")) | |
| if runConcurrently { | |
| var proxysqlCommand = concurrent.ExecCommand{ | |
| Cmd: proxysqlStop, | |
| } | |
| execList = append(execList, concurrent.ExecutionList{Logger: nil, Priority: 0, Command: proxysqlCommand}) | |
| } else { | |
| if _, err = common.RunCmd(proxysqlStop); err != nil { | |
| return emptyExecutionList, fmt.Errorf(globals.ErrWhileStoppingSandbox, path.Join(fullPath, "proxysql")) | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
runConcurrentlyis true, this block executesproxysql/stopimmediately instead of returning it as part ofexecListlike the main sandbox stop/removal steps. That breaks the function’s concurrency contract (side effects during planning) and can also run ProxySQL stop before the scheduled DB stop. Consider usingcommon.ExecExistsand, ifrunConcurrently, append aconcurrent.ExecCommandforproxysqlStopwith the same priority as the main stop; if not concurrent, run it and handle/propagate errors (instead of ignoring them) so a failed stop doesn’t silently proceed to deletion.