Skip to content

Conversation

maanpthk
Copy link

  • Modified _execute_protected_statement to use ROLLBACK on query failures
  • Added comprehensive error handling for aborted transactions
  • Prevents 'current transaction is aborted' errors on subsequent queries
  • Updated CHANGELOG.md with fix description

Fixes transaction abort issue where failed queries break session

Fixes

Summary

Changes

Fixed critical transaction abort error handling in the Redshift MCP server. Modified _execute_protected_statement function to properly execute ROLLBACK instead of END when a SQL query fails within a transaction block, preventing session corruption and subsequent query failures.

User experience

Before: When a SQL query failed, the database session would enter an aborted state, causing all subsequent queries in the same session to fail with "ERROR: current transaction is aborted, commands ignored until end of transaction block", the agent would continue to retry using the same session and would ultimately fail.

After: When a SQL query fails, the transaction is properly cleaned up with ROLLBACK, allowing the session to remain functional for subsequent queries and retries. Agent can continue using the MCP server normally after query failures, with reframed queries.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • [ x] I have reviewed the contributing guidelines
  • [ x] I have performed a self-review of this change
  • [ x] Changes have been tested
  • [x ] Changes are documented

Is this a breaking change? N

RFC issue number: N/A

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

- Modified _execute_protected_statement to use ROLLBACK on query failures
- Added comprehensive error handling for aborted transactions
- Prevents 'current transaction is aborted' errors on subsequent queries
- Updated CHANGELOG.md with fix description

Fixes transaction abort issue where failed queries break session
@maanpthk maanpthk requested review from a team and grayhemp as code owners October 10, 2025 07:55
@grayhemp grayhemp added the needs-triage This needs to be handled, it is the first automatically assigned label to issues. label Oct 10, 2025
@grayhemp grayhemp self-assigned this Oct 10, 2025
@grayhemp grayhemp changed the title fix: Handle transaction abort errors properly fix(redshift-mcp-server): Handle transaction abort errors properly Oct 10, 2025
@grayhemp
Copy link
Contributor

Looking...

@grayhemp
Copy link
Contributor

The discussion is under #1489.

@grayhemp grayhemp added the hold-merging Signals to hold the PR from merging label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold-merging Signals to hold the PR from merging needs-triage This needs to be handled, it is the first automatically assigned label to issues.

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

2 participants