How do 'transactions' in Planetscale work? #634
-
Hello, I have written a simple mysql connection pool I use in a few Python things. For standard mysql/mariadb databases this works fine, but when I try to use it with PlanetScale, the reused connections seem to generate the following error:
This is confusing, because in this particular case I am only SELECTing from this database, so I'm not sure why there's an open transaction. Could be that I'm misunderstanding something about what a transaction is supposed to mean, but as far as I was aware I thought that was only for things that modify the database. Either way, what should I do with a connection before pooling it to 'close' this transaction and avoid this error? Ideally the connection should be freed to be grabbed by whatever requests a connection from the pool next. If it helps, I am using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Can you share more about the queries you are running? My guess is the code is accidentally opening a transaction and never committing it. The only difference you should be experiencing is we have a default transaction timeout set to 20 seconds. |
Beta Was this translation helpful? Give feedback.
Heard back from some coworkers, we have seen this before with that library. Couple things to check.
autocommit
to true, solved the problem for them. This will commit any open transaction after a query is run. The default for the python connector isfalse
. https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html