dbTalk Databases Forums  

Deadlock when accessing the LockOneForWrite/Read method is SSIS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Deadlock when accessing the LockOneForWrite/Read method is SSIS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mystical potato
 
Posts: n/a

Default Deadlock when accessing the LockOneForWrite/Read method is SSIS - 04-23-2006 , 06:46 PM






I'm writing my first SSIS package and am running into some problems that I
could use a hand with.

i'm using a For Loop Container to do two things:

1) Use a FTP task to look for a file on a remote server
2) On Success use the Script Task to set a package variable to False so
the loop stops and the packages continues. If the file is not presnet I set
the thread to sleep for 5 minutes using the Script Taks and loop to check
again.

I created a package level variable called bolSTIUpdateInProcess (default val
= True)
The EvalExpression of the loop is set to @bolSTIUpdateInProcess = True

The following script runs when I want to exit the loop
Public Sub Main()
Dim vars As Variables
If Dts.Variables.Contains("bolSTIUpdateInProcess") Then
'The next lines produces a deadlock error
Dts.VariableDispenser.LockOneForWrite("bolSTIUpdat eInProcess",
vars)
vars("bolSTIUpdateInProcess").Value = False
vars.Unlock()
End If
Dts.TaskResult = Dts.Results.Success
End Sub

The packages produces an error when I try to execute the LockOneForWrite
method so I can change the value of bolSTIUpdateInProcess. Is the variable
locked because the EvalExpression of the containing For Loop is using it?

If anyone could lend a hand I would appreciate it.

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSIS - 04-24-2006 , 06:37 AM






Your Eval expression is an assignment expression, did you just miss a =

Are you not using the ReadOnlyVariables and ReadWriteVariables collections
on the Script task designer? This will tell the task to do the locking for
you

Why would you need to check for the existence of the variable? Surely you
created it and know it is there and also you are using it in your eval
expression?

OK. So if you include the variable in the Task's ReadWriteVariables
Collection and in the task you try to lock the variable explicitly you will
get a deadlock.

If you remove the variable from one of these two places then you should be
OK



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:113C18BA-FE9A-4F34-96B3-37A16333BD45 (AT) microsoft (DOT) com...
Quote:
I'm writing my first SSIS package and am running into some problems that I
could use a hand with.

i'm using a For Loop Container to do two things:

1) Use a FTP task to look for a file on a remote server
2) On Success use the Script Task to set a package variable to False so
the loop stops and the packages continues. If the file is not presnet I
set
the thread to sleep for 5 minutes using the Script Taks and loop to check
again.

I created a package level variable called bolSTIUpdateInProcess (default
val
= True)
The EvalExpression of the loop is set to @bolSTIUpdateInProcess = True

The following script runs when I want to exit the loop
Public Sub Main()
Dim vars As Variables
If Dts.Variables.Contains("bolSTIUpdateInProcess") Then
'The next lines produces a deadlock error
Dts.VariableDispenser.LockOneForWrite("bolSTIUpdat eInProcess",
vars)
vars("bolSTIUpdateInProcess").Value = False
vars.Unlock()
End If
Dts.TaskResult = Dts.Results.Success
End Sub

The packages produces an error when I try to execute the LockOneForWrite
method so I can change the value of bolSTIUpdateInProcess. Is the
variable
locked because the EvalExpression of the containing For Loop is using it?

If anyone could lend a hand I would appreciate it.



Reply With Quote
  #3  
Old   
mystical potato
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSI - 04-24-2006 , 08:30 AM



Allan,

thanks for the reply.

I did miss an "=" in the expression (that's the VB in me). Maybe I should
take a step back and just say what I'm
looking to do and get some feedback based on that. I need to loop through a
series of tasks until an event inside
the loop occurs (e.g. I retrieve a file from an ftp server). How can I set
some flag inside the loop which will
indicate that the loop should end?

thanks,
Scott


"Allan Mitchell" wrote:

Quote:
Your Eval expression is an assignment expression, did you just miss a =

Are you not using the ReadOnlyVariables and ReadWriteVariables collections
on the Script task designer? This will tell the task to do the locking for
you

Why would you need to check for the existence of the variable? Surely you
created it and know it is there and also you are using it in your eval
expression?

OK. So if you include the variable in the Task's ReadWriteVariables
Collection and in the task you try to lock the variable explicitly you will
get a deadlock.

If you remove the variable from one of these two places then you should be
OK



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:113C18BA-FE9A-4F34-96B3-37A16333BD45 (AT) microsoft (DOT) com...
I'm writing my first SSIS package and am running into some problems that I
could use a hand with.

i'm using a For Loop Container to do two things:

1) Use a FTP task to look for a file on a remote server
2) On Success use the Script Task to set a package variable to False so
the loop stops and the packages continues. If the file is not presnet I
set
the thread to sleep for 5 minutes using the Script Taks and loop to check
again.

I created a package level variable called bolSTIUpdateInProcess (default
val
= True)
The EvalExpression of the loop is set to @bolSTIUpdateInProcess = True

The following script runs when I want to exit the loop
Public Sub Main()
Dim vars As Variables
If Dts.Variables.Contains("bolSTIUpdateInProcess") Then
'The next lines produces a deadlock error
Dts.VariableDispenser.LockOneForWrite("bolSTIUpdat eInProcess",
vars)
vars("bolSTIUpdateInProcess").Value = False
vars.Unlock()
End If
Dts.TaskResult = Dts.Results.Success
End Sub

The packages produces an error when I try to execute the LockOneForWrite
method so I can change the value of bolSTIUpdateInProcess. Is the
variable
locked because the EvalExpression of the containing For Loop is using it?

If anyone could lend a hand I would appreciate it.




Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSI - 04-24-2006 , 08:45 AM



You can do it how you are doing it or you can use the result of something to
trigger the end so maybe your process asks the question "How may rows in
this table?" In your loop you query the DB and assign the value returned
from the COUNT(*) to a variable.

So your init expression might look like this

@myVar = 0

Your eval expression might look like

@myVar <= @MyThresholdVar


You are approaching it in the right way but I think in this example you are
possibly trying to lock the same variable twice in the script task. Once in
the designer and once in code.

--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:E9F7F1A4-6CCF-44FA-B1A5-58B62625BCB4 (AT) microsoft (DOT) com...
Quote:
Allan,

thanks for the reply.

I did miss an "=" in the expression (that's the VB in me). Maybe I should
take a step back and just say what I'm
looking to do and get some feedback based on that. I need to loop through
a
series of tasks until an event inside
the loop occurs (e.g. I retrieve a file from an ftp server). How can I
set
some flag inside the loop which will
indicate that the loop should end?

thanks,
Scott


"Allan Mitchell" wrote:

Your Eval expression is an assignment expression, did you just miss a =

Are you not using the ReadOnlyVariables and ReadWriteVariables
collections
on the Script task designer? This will tell the task to do the locking
for
you

Why would you need to check for the existence of the variable? Surely
you
created it and know it is there and also you are using it in your eval
expression?

OK. So if you include the variable in the Task's ReadWriteVariables
Collection and in the task you try to lock the variable explicitly you
will
get a deadlock.

If you remove the variable from one of these two places then you should
be
OK



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:113C18BA-FE9A-4F34-96B3-37A16333BD45 (AT) microsoft (DOT) com...
I'm writing my first SSIS package and am running into some problems
that I
could use a hand with.

i'm using a For Loop Container to do two things:

1) Use a FTP task to look for a file on a remote server
2) On Success use the Script Task to set a package variable to False
so
the loop stops and the packages continues. If the file is not presnet
I
set
the thread to sleep for 5 minutes using the Script Taks and loop to
check
again.

I created a package level variable called bolSTIUpdateInProcess
(default
val
= True)
The EvalExpression of the loop is set to @bolSTIUpdateInProcess = True

The following script runs when I want to exit the loop
Public Sub Main()
Dim vars As Variables
If Dts.Variables.Contains("bolSTIUpdateInProcess") Then
'The next lines produces a deadlock error

Dts.VariableDispenser.LockOneForWrite("bolSTIUpdat eInProcess",
vars)
vars("bolSTIUpdateInProcess").Value = False
vars.Unlock()
End If
Dts.TaskResult = Dts.Results.Success
End Sub

The packages produces an error when I try to execute the
LockOneForWrite
method so I can change the value of bolSTIUpdateInProcess. Is the
variable
locked because the EvalExpression of the containing For Loop is using
it?

If anyone could lend a hand I would appreciate it.






Reply With Quote
  #5  
Old   
mystical potato
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSI - 04-24-2006 , 10:04 AM



I've changed the package to approach the eval expression the way you indicated

---LoopTask
InitialExpression (@Threshold = 0)
EvalExpression (@Threshold <= @Actual)
----Script Task
....Sub
Dim vars As Variables
Dts.VariableDispenser.LockOneForWrite("Actual", vars)
vars("Actual").Value = 2
vars.Unlock()
Dts.TaskResult = Dts.Results.Success
....End

And again I'm using variables with a scope of Package, they are not
read-only and I have them in the script task under the ReadWrite collection.

And this did not solve the issue. I gave up and created a new project with
just the For Loop, FTP and Script tasks and this still produces a deadlock.
It is really ffrustrating that something this simple is such a problem.

I hadn't mentioned this before but I'm working in VS05 Pro disconnected from
sql. Would this make a difference in this instance?

Sorry to keep bothering you with this. Would it help if I sent you the
dtsx? Here's my address if you want to shoot me an e-mail (this way you
don't have to post your address). sodonnel AT optonline.net

"Allan Mitchell" wrote:

Quote:
You can do it how you are doing it or you can use the result of something to
trigger the end so maybe your process asks the question "How may rows in
this table?" In your loop you query the DB and assign the value returned
from the COUNT(*) to a variable.

So your init expression might look like this

@myVar = 0

Your eval expression might look like

@myVar <= @MyThresholdVar


You are approaching it in the right way but I think in this example you are
possibly trying to lock the same variable twice in the script task. Once in
the designer and once in code.

Reply With Quote
  #6  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSI - 04-24-2006 , 10:11 AM



No.

Either lock the variables in the code OR lock them by placing them in the
ReadWriteVariables collection not both.



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:24FF8792-0DC0-4686-BEB8-B4D8D90A0D0A (AT) microsoft (DOT) com...
Quote:
I've changed the package to approach the eval expression the way you
indicated

---LoopTask
InitialExpression (@Threshold = 0)
EvalExpression (@Threshold <= @Actual)
----Script Task
...Sub
Dim vars As Variables
Dts.VariableDispenser.LockOneForWrite("Actual", vars)
vars("Actual").Value = 2
vars.Unlock()
Dts.TaskResult = Dts.Results.Success
...End

And again I'm using variables with a scope of Package, they are not
read-only and I have them in the script task under the ReadWrite
collection.

And this did not solve the issue. I gave up and created a new project
with
just the For Loop, FTP and Script tasks and this still produces a
deadlock.
It is really ffrustrating that something this simple is such a problem.

I hadn't mentioned this before but I'm working in VS05 Pro disconnected
from
sql. Would this make a difference in this instance?

Sorry to keep bothering you with this. Would it help if I sent you the
dtsx? Here's my address if you want to shoot me an e-mail (this way you
don't have to post your address). sodonnel AT optonline.net

"Allan Mitchell" wrote:

You can do it how you are doing it or you can use the result of something
to
trigger the end so maybe your process asks the question "How may rows in
this table?" In your loop you query the DB and assign the value returned
from the COUNT(*) to a variable.

So your init expression might look like this

@myVar = 0

Your eval expression might look like

@myVar <= @MyThresholdVar


You are approaching it in the right way but I think in this example you
are
possibly trying to lock the same variable twice in the script task. Once
in
the designer and once in code.



Reply With Quote
  #7  
Old   
mystical potato
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSI - 04-24-2006 , 10:35 AM



Grrrr!!

Thanks! It now works. Wrox's Pro SSIS doesn't really make that point (at
least not early on in the book). I appreciate your patience and especially
your help.

Scott


"Allan Mitchell" wrote:

Quote:
No.

Either lock the variables in the code OR lock them by placing them in the
ReadWriteVariables collection not both.



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:24FF8792-0DC0-4686-BEB8-B4D8D90A0D0A (AT) microsoft (DOT) com...
I've changed the package to approach the eval expression the way you
indicated

---LoopTask
InitialExpression (@Threshold = 0)
EvalExpression (@Threshold <= @Actual)
----Script Task
...Sub
Dim vars As Variables
Dts.VariableDispenser.LockOneForWrite("Actual", vars)
vars("Actual").Value = 2
vars.Unlock()
Dts.TaskResult = Dts.Results.Success
...End

And again I'm using variables with a scope of Package, they are not
read-only and I have them in the script task under the ReadWrite
collection.

And this did not solve the issue. I gave up and created a new project
with
just the For Loop, FTP and Script tasks and this still produces a
deadlock.
It is really ffrustrating that something this simple is such a problem.

I hadn't mentioned this before but I'm working in VS05 Pro disconnected
from
sql. Would this make a difference in this instance?

Sorry to keep bothering you with this. Would it help if I sent you the
dtsx? Here's my address if you want to shoot me an e-mail (this way you
don't have to post your address). sodonnel AT optonline.net

"Allan Mitchell" wrote:

You can do it how you are doing it or you can use the result of something
to
trigger the end so maybe your process asks the question "How may rows in
this table?" In your loop you query the DB and assign the value returned
from the COUNT(*) to a variable.

So your init expression might look like this

@myVar = 0

Your eval expression might look like

@myVar <= @MyThresholdVar


You are approaching it in the right way but I think in this example you
are
possibly trying to lock the same variable twice in the script task. Once
in
the designer and once in code.




Reply With Quote
  #8  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Deadlock when accessing the LockOneForWrite/Read method is SSI - 04-24-2006 , 10:47 AM



Mine are the later chapters so I am out of the frame for that <grin>

--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:1E7F3D97-B7EA-4A60-9136-FF992DCFF518 (AT) microsoft (DOT) com...
Quote:
Grrrr!!

Thanks! It now works. Wrox's Pro SSIS doesn't really make that point (at
least not early on in the book). I appreciate your patience and
especially
your help.

Scott


"Allan Mitchell" wrote:

No.

Either lock the variables in the code OR lock them by placing them in the
ReadWriteVariables collection not both.



--


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com


"mystical potato" <mysticalpotato (AT) discussions (DOT) microsoft.com> wrote in
message news:24FF8792-0DC0-4686-BEB8-B4D8D90A0D0A (AT) microsoft (DOT) com...
I've changed the package to approach the eval expression the way you
indicated

---LoopTask
InitialExpression (@Threshold = 0)
EvalExpression (@Threshold <= @Actual)
----Script Task
...Sub
Dim vars As Variables
Dts.VariableDispenser.LockOneForWrite("Actual", vars)
vars("Actual").Value = 2
vars.Unlock()
Dts.TaskResult = Dts.Results.Success
...End

And again I'm using variables with a scope of Package, they are not
read-only and I have them in the script task under the ReadWrite
collection.

And this did not solve the issue. I gave up and created a new project
with
just the For Loop, FTP and Script tasks and this still produces a
deadlock.
It is really ffrustrating that something this simple is such a problem.

I hadn't mentioned this before but I'm working in VS05 Pro disconnected
from
sql. Would this make a difference in this instance?

Sorry to keep bothering you with this. Would it help if I sent you the
dtsx? Here's my address if you want to shoot me an e-mail (this way
you
don't have to post your address). sodonnel AT optonline.net

"Allan Mitchell" wrote:

You can do it how you are doing it or you can use the result of
something
to
trigger the end so maybe your process asks the question "How may rows
in
this table?" In your loop you query the DB and assign the value
returned
from the COUNT(*) to a variable.

So your init expression might look like this

@myVar = 0

Your eval expression might look like

@myVar <= @MyThresholdVar


You are approaching it in the right way but I think in this example
you
are
possibly trying to lock the same variable twice in the script task.
Once
in
the designer and once in code.






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.