autocommit on long transaction after connection failure

Posted on

Question :

Is there any spec on what impact a connection failure has on a mutation statement if autocommit is on?

For example, if a client starts, in autocommit mode, a mutation that can take a long time and then goes away, is it defined whether this will or will not commit?

For various reasons, we don’t have the ability to add a start transaction before the statement which I assume would automatically rollback if the connection failed before sending a commit.

I suspect the behavior is not defined but thought I’d ask.

Mostly wondering about mysql and pg.

Answer :

It will automatically rollback.

But… If you do not catch the “go away”, but automatically reconnect and proceed with the other statements in the transaction, you could have a mess — whether it is autocommit or not.

So, always check for errors and take evasive action.

Leave a Reply

Your email address will not be published. Required fields are marked *