What happens when SQL Transaction commit passes, but client timeouts/fails

Viewed 218

What is the expected behavior of SQL if the transaction is committed to the database, it is successfully written to the database, but client fails in some way (timeout, network problem) and the final information that transaction is committed never reaches the client. So the final state is: transaction is committed and the client time-outed or failed in some unusual way. Does this leave database in dirty state where client thinks that transaction is not committed or SQL will ensure that if this information doesn't reach client, the transaction will be aborted?

1 Answers

If you don't explicitly commit it when you execute it, it rolls back. At least for Oracle databases, I would imagine other SQL databases do the same thing.

If you do explicitly commit and execute it and your client-side program crashes or something before it returns a result, it doesn't really matter as it's in the databases hand now, not the clients computer. You would just relaunch your client-side program and just see the results of your query there.

Sources: https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4010.htm https://docs.oracle.com/cd/B19306_01/server.102/b14220/transact.htm#CNCPT016

Related