on 2014 Sep 18 4:52 AM
I have the need to update a table after a transaction is finished. To achieve this I use a EVENT that is started in a TRIGGER. To allow the transaction to finish I us WAITFOR DELAY inside the EVENT HANDLER. Some times it happened that the transaction in the EVENT caused a (dead) lock to the normal operations.
To reduce the risk of a block I would like that the EVENT tasks don't wait forever to get a lock.
CREATE EVENT "DONT_BLOCK_EVENT" ENABLE AT ALL HANDLER BEGIN DECLARE @sqlcode INTEGER; DECLARE @sqlstate VARCHAR ( 5 ); DECLARE @errormsg VARCHAR ( 32767 ); -- If we can't get a Lock wait maximum 1000ms SET TEMPORARY OPTION blocking_timeout = 1000; -- If this event blocks other connections we give up after 500ms SET TEMPORARY OPTION blocking_others_timeout = 500; if CAST( EVENT_PARAMETER('NumActive') as INTEGER ) = 1 then -- Hold the processing to give the calling worker the possibility to finish its task WAITFOR DELAY '00:00:05'; // Do some Stuff here end if; EXCEPTION WHEN OTHERS THEN select string ( 'EXCEPTION: SQLCODE = ', SQLCODE, ', SQLSTATE = ', SQLSTATE, ', ERRORMSG() = ', ERRORMSG() ) into @errormsg; message @errormsg type info to console; END;
When I run
trigger event DONT_BLOCK_EVENT
from iSQL the console I get
EXCEPTION: SQLCODE = -201, SQLSTATE = 42W17, ERRORMSG() = Invalid setting for option 'blocking_others_timeout'
Probably I have missunderstood the concept here. Would be great if somebody can enlighten me.
Thanks
Just in case the thought got lost in the forest of comments... this is has gotta be a bug 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.