Skip to content

Fix database dump silent failures on cursor close errors - #1343

Merged
no-itsbackpack merged 5 commits into
mainfrom
cursor/fix-dump-cursor-close-ef59
Aug 17, 2026
Merged

Fix database dump silent failures on cursor close errors#1343
no-itsbackpack merged 5 commits into
mainfrom
cursor/fix-dump-cursor-close-ef59

Conversation

@no-itsbackpack

@no-itsbackpack no-itsbackpack commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a regression introduced in commit 4d3dc85 where pscale database dump could finish successfully after a partial dump when the MySQL stream failed mid-query.

Root cause

When refactoring dumpTable for multiple output formats, the explicit cursor.Close() error check was replaced with defer cursor.Close(). In go-mysqlstack, stream errors (e.g. unexpected EOF, closed network connection) are often only returned from Close() after Next() stops, so those errors were swallowed and dumpTable returned success.

Changes

  • Restore an explicit cursor.Close() check after finishing the row loop and writer flush.
  • Propagate dumpTable errors from errgroup workers so Run() fails and pscale database dump exits non-zero.
  • Add tests for cursor close error propagation and dump failure exit behavior.

Commit 4d3dc85 replaced an explicit cursor.Close() check with defer
cursor.Close(), which swallowed stream errors from go-mysqlstack that
only surface when the cursor is closed after Next() stops.

Also propagate dumpTable errors from errgroup workers so failed dumps
return a non-zero exit code instead of logging and continuing.

Co-authored-by: Gomez <no-itsbackpack@users.noreply.github.com>
@no-itsbackpack
no-itsbackpack marked this pull request as ready for review August 17, 2026 17:14
@no-itsbackpack
no-itsbackpack requested a review from a team as a code owner August 17, 2026 17:14
Comment thread internal/dumper/dumper.go

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium. Left a non-blocking comment; no reviewers assigned. Cursor Bugbot reported an unresolved high-severity cursor leak on early exits, so this PR is not approved and needs human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: cli-reviewer

Keep Close error reporting via a named return defer so mid-loop failures
still drain the stream before the connection returns to the pool.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread internal/dumper/dumper.go
no-itsbackpack and others added 2 commits August 17, 2026 12:35
Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid a misleading "dumping table done" log when the deferred stream
close is what fails the dump.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c144386. Configure here.

Comment thread internal/dumper/dumper.go Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
@no-itsbackpack
no-itsbackpack merged commit 023e787 into main Aug 17, 2026
4 checks passed
@no-itsbackpack
no-itsbackpack deleted the cursor/fix-dump-cursor-close-ef59 branch August 17, 2026 17:51
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.

3 participants