Search code examples
google-cloud-platformgoogle-cloud-spanner

Locks and commit failures


Here is the scenario. I lock a row in a read write transaction and then commit the transaction. If the commit is successful, that will release the lock as well. What if the commit is failed for some reason? Should I explicitly Rollback the transaction to release the locks or the commit failure would automatically release any locks. ?


Solution

  • Locks are released on failure. You only need to call rollback if you don't issue the session.commit request.