Aurora DSQL - BEGIN/COMMIT won't work :(

Hi, we have a PHP project on Phalcon MVC. We recently migrated from SQL to Aurora DSQL. I created the relevant adapter file extending Postgres Adaptor from PDO.

All transactions work just fine but as soon as I wrap any transaction in BEGIN/COMMIT it fails. There is no error/exception whatsoever but there is no data in the DB. If I attempt raw psql queries wrapped in BEGIN/COMMIT they also work just fine. So something in Phalcon adapter is silently crashing.

I have made sure that begin, commit and transaction happen on the same connection. Auto-commit is off.

Has anyone else faced this issue working with PHP and Aurora DSQL? Could it just be a Phalcon ORM issue?

Any guidance will be highly appreciated.


Related discussions:

Access your Amazon Aurora Serverless Database with the New Data API (Beta)
When will Aurora Serverless support MySQL >=5.7?
How do I upgrade Aurora Postgres from v9.6.9 to v10?
Aurora Postgres not suitable for production?
Anyone in the Aurora Serverless Postgres preview?
Is AWS Redshift overkill of small-medium sized Data Warehouse?
Help me understand Aurora Serverless pricing?
Aurora MySQL Multi-Master is Now Generally Available
Review: Amazon Aurora Serverless - A cloud-native and production-ready relational database?
RDS: Max CPU before scaling, best practice?
Application cache with Lambda
Lambda provisioned concurrency with Aurora Serverless - should I use the Data API?
Yikes: AWS Aurora PostgreSQL versions vanish from the mega-cloud for days, leaving customers in the dark
AWS Aurora IOPS vs RDS IOPS
Is CloudFront really expensive or am i calculating data transfer wrong ?
Multiple Aurora Serverless v2 instances per cluster?
Lambdas - Implementing RDS Proxy
Update your rds-ca-2019 certificates in the next 8hours!
Introducing scaling to 0 capacity with Amazon Aurora Serverless v2
Benchmarking Amazon Aurora Against Google Cloud SQL
Fastest way to create Postgres aurora with obfuscated production data
Performance impact after migrating to Aurora Global Database ?
Performance Triage in Aurora
Got Cloud Practitioner yesterday
For Aurora Global Database, is it true that you cannot manually configure the number of replicas or control the cross region failover ?
Passed the SAA-CO3 on second attempt yesterday!
Which of the following is a cheaper set up and why?
Which option would you choose?
Best way to get practical experience in AWS
Understanding whether Aurora charges per tenant
Serverless Aurora: What it means and why it's the future of data
ap-southeast-1c now showing up in APIs
Amazon Aurora is Compatible with MySQL 5.7
Question about upgrading Aurora MySQL cluster - Will I have an outage?
Amazon Aurora Now Supports Stopping and Starting of Database Clusters

I have created some Rust Lambdas speaking to Aurora DSQL and I am using the Rust connector to start and commit transactions. Is there a PHP connector for your library for that as well?

We’re using the Postgres Adaptor PDO that comes built in with Phalcon

Moderators, please consider using your LLM to parse the OP’s post to decide if it’s sufficiently detailed that a generic “Here are a few handy links” response would be unhelpful and effectively spamming the channel. Thanks.

TL;DR: There’s a bug in pdo_pgsql’s prep stmt handling. Fix is: PDO::ATTR_EMULATE_PREPARES => true.

I spent a little time reproing the issue and getting a wire capture from PHP → DSQL. Here’s what’s happening on the failing BEGIN/INSERT/COMMIT:

F Query “BEGIN” → OK, tx open
F Parse/Bind/Execute “INSERT …” → OK, row accepted
F Query “DEALLOCATE pdo_stmt_1” ← pdo_pgsql auto-cleanup
B ERROR 0A000 “DEALLOCATE not supported”
B ReadyForQuery ‘E’ – tx is now poisoned
F Query “COMMIT”
B CommandComplete “ROLLBACK” – PG semantics: commit on failed tx = rollback

A few things conspire:

  1. PHP’s pdo_pgsql sends DEALLOCATE <name> after every prepared statement.
  2. DSQL doesn’t implement DEALLOCATE <name> yet, so this returns an error to the client.
  3. Error-inside-tx → tx aborted → next COMMIT silently returns ROLLBACK.

PHP never sees an exception because the DEALLOCATE wasn’t in your code — it’s in pdo_pgsql’s destructor. Your INSERT returned success, your COMMIT returned a CommandComplete, but your row is gone because of the rollback. pdo_pgsql calls deallocate unconditionally and ignores the response, so it’s not showing that the transaction has entered an error.

Phalcon’s query() goes through extended-prepare so it triggers this; execute() uses simple-query so it doesn’t.

Fix:

‘options’ => [
PDO::ATTR_EMULATE_PREPARES => true,
],

Emulated prepares bypass libpq’s extended protocol entirely → no DEALLOCATE → no silent rollback. I verified that by adding that transactions succeed.

Also another tip, if you use Phalcon’s Transaction Manager: it defaults to SAVEPOINT-based nested transactions and DSQL doesn’t support SAVEPOINT either. Add $db->setNestedTransactionsWithSavepoints(false).

Sorry the bot is from 1994. Best we can do is a keyword match. I see you’re talking about Aurora, heres links to all our documentation on every database and some other database-like stuff.

I’ve filed a bug report to pdo_pgsql regarding this: https://github.com/php/php-src/issues/21869

It worked!! I spent 2 weeks struggling with it before finally posting on Reddit. I wanna know 2 things

  1. Your BuyMeACoffee link. For some reason Reddit crashes when I try to buy an award on my phone and I really want to get you a nice cup of coffee as thank you.

  2. How did you debug this? I literally threw everything at it, with logs after every single line of code but couldn’t get to this.

Again, massive massive thank you!!

No problem, happy to help!

I actually work on DSQL so I’m pretty familiar with which parts of the Postgres syntax we don’t support yet. I was able to get a repro going from your description with some agentic help, and from there I used PQtrace to get a capture of the client/server packets being sent. That was what I needed to see the above.

The Postgres extended query protocol can get a little funky across all of the implementations, and DEALLOCATE typically never fails so some clients ignore the response. DEALLOCATE syntax support is on the roadmap and will be coming to DSQL in the future!

Thanks for the contributions to Aurora DSQL & back to the community, u/benjscho !

Thanks, Ben. Genuinely appreciate you investing your time and efforts into this,