SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using a TSQL semaphore in SSIS


Using a TSQL semaphore in SSIS

Author
Message
Federico Iori
Federico Iori
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 300
Comments posted to this topic are about the item Using a TSQL semaphore in SSIS
Cade Roux
Cade Roux
SSC Veteran
SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)

Group: General Forum Members
Points: 220 Visits: 491
Any particular reason that sp_getapplock wasn't used for this implementation?

http://msdn.microsoft.com/en-us/library/ms189823.aspx
Federico Iori
Federico Iori
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 300
Yes, you are right, built-in sp_getapplock could be used in my solution instead of the user-defined semaphore table drop_fi_semaphore
, but the structure of the SSIS package would remain unchanged .
The only changed block will be Get Semaphore .
greg 15422
greg 15422
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 24
Thanks for the post.

A useful addition would be how to release the semaphore from within the package. A fairly common use case is to have a queue and want to hold the semaphore while you are selecting the next item from the queue.

Ill also check out spappLock

Thanks again.
Federico Iori
Federico Iori
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 300
Release the semaphore : just end the transaction that is holding the semaphore by a commit ( or rollback, is the same since no data are modified) ...
Henry B. Stinson
Henry B. Stinson
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 Visits: 79
Two problems I see right off:
1. You may not want isolation level serializable for the whole package. That may cause unnecessary blocking in other processes.
2. if the data flow fails, the semaphore is not released.
SAinCA
SAinCA
SSC Veteran
SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)

Group: General Forum Members
Points: 208 Visits: 695
Cade Roux (1/13/2013)
Any particular reason that sp_getapplock wasn't used for this implementation?

http://msdn.microsoft.com/en-us/library/ms189823.aspx

Thanks for pointing this out... My predecessor used a data update of all rows with a fake column value to get around this and the whole thing was a nasty can of worms. sp_getapplock is so clean!
Federico Iori
Federico Iori
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 300
Henry B. Stinson (1/14/2013)
Two problems I see right off:
1. You may not want isolation level serializable for the whole package. That may cause unnecessary blocking in other processes.

I suppose you are rigth , I should be enough to set isolation level serializable for the single components

2. if the data flow fails, the semaphore is not released.

If the data flow fails, the semaphore is released . The semaphore is designed in such a way, that cannot remain unreleased if the session terminates
The semaphore is acquired by putting a lock on a row :
begin tran
select * from drop_fi_semaforo with ( rowlock, UPDLOCK, holdlock) where Uno = '1'

There is nothing to commit or rollback , since data are not modified .
If the session is terminated, the lock is released, the DBMS takes care of it
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search