Marking failing updates

Fixes problems with marking update as failed. In the previous solution, we were marking it, and then calling rollback (because of exception raised) - so the change was not stored in db. Currently we are marking them as failed in after_rollback sequel gem hook.

Some tests related to the bug above were hard to investigate because of transactional nature of rspec cleaning strategy, thus I flagged some of the test cases and setup truncation strategy for them.

Also, I noticed that at some point we can run into deadlock with our previous lock mechanism, and I found probably more stable and thread-safe solution to handle that.

I also did some refactoring.