Release another custom lock obtained with sp_getapplock on SQL Server

We have a system that uses sp_getapplockto create an exclusive mutex at any time when someone opens an order in a graphical interface. This is used to prevent multiple changes being made to the order at the same time.

Sometimes people open an order and go home, leaving it open. This actually blocks anyone who can make changes to the order. Then I receive letters, calls and finish work with the kill <spid>enterprise manager. Obviously, I'm tired of it, and I want to quickly create a self-service web form.

The main problem I encountered is that it killrequires system administrator privileges that I do not want to give the user what our site works like. I tried sp_releaseapplock, but this does not allow you to release another custom lock (even when calling it as sysadmin).

So finally my question; Does anyone know of an alternative method to release a lock that was obtained by another user using sp_getapplock?

+3
source share
1 answer

The documentation is pretty straightforward:

, , , . , , , . , , . - , .

- , , , , .

- concurrency? , .. . , ( ) .

applocks concurrency, , - spid, .

sysadmin , , WITH EXECUTE AS <admin_user>... , , , , .

+7

Source: https://habr.com/ru/post/1743098/


All Articles