If db.beginTransaction() fails for any reason the lock will not be unlocked.
I did not fix the indentation so you can see the changes properly.
Merge pull request #1939 from davidmartinzeus/master

If db.beginTransaction() fails for any reason the lock will not be unlocked