Is it really necessary to use SQL LOCK for ythe "mutex"?
Could we just use some table "lock" with fields: "id", "timeout" etc? Such solution may be bold, but it can be universal for different DBMS and will not require separated implementation.