Revert "Revert "#2088 LOCK not released in SQL UPDATE-PESSIMISTIC LOCK""

This reverts commit 2508b3e6411b5d0cffb0fdc8256426c30673d20c.
Merge pull request #2136 from kowalot/develop

#2088 LOCK not released in SQL UPDATE-PESSIMISTIC LOCK