Skip to content

Handle ProxySQL cleanup during sandbox deletion#48

Merged
renecannao merged 1 commit intomasterfrom
phase2b/task7-proxysql-delete-cleanup
Mar 24, 2026
Merged

Handle ProxySQL cleanup during sandbox deletion#48
renecannao merged 1 commit intomasterfrom
phase2b/task7-proxysql-delete-cleanup

Conversation

@renecannao
Copy link
Copy Markdown

Closes #42

Summary

  • Before a sandbox directory is removed during dbdeployer delete, check if a proxysql/ subdirectory exists with a stop script
  • If found, run proxysql/stop to gracefully shut down the ProxySQL process before the directory is deleted
  • Applied to both RemoveSandbox (deprecated) and RemoveCustomSandbox functions

Test plan

  • Build succeeds: go build -o dbdeployer .
  • dbdeployer delete works normally for sandboxes without ProxySQL
  • dbdeployer delete stops ProxySQL before cleanup for sandboxes with a proxysql/ subdirectory

Copilot AI review requested due to automatic review settings March 24, 2026 01:50
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Warning

Rate limit exceeded

@renecannao has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 21 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3681017b-4e8f-4084-8b9f-2269818485c5

📥 Commits

Reviewing files that changed from the base of the PR and between 5402472 and 0f3b1b4.

📒 Files selected for processing (1)
  • sandbox/sandbox.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch phase2b/task7-proxysql-delete-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@renecannao renecannao merged commit cec852c into master Mar 24, 2026
6 of 16 checks passed
@renecannao renecannao deleted the phase2b/task7-proxysql-delete-cleanup branch March 24, 2026 01:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves sandbox deletion (dbdeployer delete) by attempting to gracefully stop an embedded ProxySQL “sub-sandbox” (via proxysql/stop) before removing the sandbox directory, aligning deletion behavior with setups that include ProxySQL.

Changes:

  • Detect proxysql/stop under the sandbox directory and run it before deleting files.
  • Apply the same ProxySQL stop behavior to both RemoveSandbox (deprecated) and RemoveCustomSandbox.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sandbox/sandbox.go
Comment on lines +1249 to +1252
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)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

When runConcurrently is true, this block executes proxysql/stop immediately instead of returning it as part of execList like 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 using common.ExecExists and, if runConcurrently, append a concurrent.ExecCommand for proxysqlStop with 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.

Suggested change
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)
proxysqlSandbox := path.Join(fullPath, "proxysql")
proxysqlStop := path.Join(proxysqlSandbox, "stop")
if common.ExecExists(proxysqlStop) {
if runConcurrently {
var proxysqlCommand = concurrent.ExecCommand{
Cmd: proxysqlStop,
Args: []string{},
}
// Use the same priority as the main stop command
execList = append(execList, concurrent.ExecutionList{Logger: nil, Priority: 0, Command: proxysqlCommand})
} else {
common.CondPrintf("Stopping ProxySQL in %s\n", proxysqlSandbox)
_, err = common.RunCmd(proxysqlStop)
if err != nil {
return emptyExecutionList, fmt.Errorf("error while stopping ProxySQL in %s: %s", proxysqlSandbox, err)
}
}

Copilot uses AI. Check for mistakes.
Comment thread sandbox/sandbox.go
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)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Same issue here as in RemoveSandbox: this runs proxysql/stop synchronously even when runConcurrently is true, and it ignores execution errors. Please make ProxySQL stop follow the same execution model as the rest of the deletion workflow (enqueue as a priority-0 task when concurrent; otherwise run and handle/propagate errors). Also prefer common.ExecExists over os.Stat so we only attempt to execute an actually-executable stop script.

Suggested change
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"))
}
}

Copilot uses AI. Check for mistakes.
Comment thread sandbox/sandbox.go
Comment on lines +1248 to +1253
// 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)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

New behavior (detecting and stopping a proxysql/stop script) isn’t covered by tests. Since sandbox/sandbox_test.go already exercises sandbox removal paths, please add a unit/integration-style test that creates a proxysql/stop script (e.g., one that writes a sentinel file) and asserts it is invoked during deletion, both for the concurrent and non-concurrent paths (as applicable).

Copilot uses AI. Check for mistakes.
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.

Handle ProxySQL cleanup during sandbox deletion

2 participants