3

I have a package with a Foreach Container and Execute Process Task inside ForEach Container . On some error in Execute Process Task it redirects to OnError Event handler of ForEach Container.

I am capturing the Error from .exe using StandardErrorvariable property of the Task and using this in the script task which is present in OnError Event Handler.

The Script Task fails saying

Error: A deadlock was detected while trying to lock variable "User::ErrorExcelName, User::ErrorFolder, User::ErrorMessage, User::FileName" for read access. A lock could not be acquired after 16 attempts and timed out.

How to fix this ?

Hadi
  • 36,233
  • 13
  • 65
  • 124
Sai Bhasker Raju
  • 531
  • 1
  • 7
  • 20

1 Answers1

0

You can easily resolve the problem by managing the variable locking explicitly in code. (Not adding variables to ReadOnlyVariables and ReadWriteVariables properties.

string strFilename;
Variables lockedVariables = null;
Dts.VariableDispenser.LockOneForRead("FileName", ref lockedVariables);
strFilename = lockedVariables["FileName"].Value;
lockedVariables.Unlock();

References

Hadi
  • 36,233
  • 13
  • 65
  • 124
  • Thanks @Hadi , but the result is Negative again. I added try catch in the script block and added the above few lines of code. When i ran i get the same old deadlock error in the catch block. How can we be sure that **Execute Process Task ** has released all its variables. As per the links you sent, variables are released and locked on used and later unlocked. So is it like **Task** is still using it or what. – Sai Bhasker Raju Jun 12 '17 at 09:02
  • Try setting the `execute process task` and `script task` `Delay validation` property = True, variable may be lock in validation phase – Hadi Jun 17 '17 at 11:22
  • Nope if i add delay validation to script task ..its not even opening the script window in debug mode and its looping .. I observed one more thing ..i have few console.writeline()'s in my app but when i add any variable to the **Process** tab of **Execute Process Task** , the screen fades out and nothing displays – Sai Bhasker Raju Jun 21 '17 at 12:14
  • @Hadi I have a similar issue can you please help me here https://stackoverflow.com/questions/70187327/ssis-script-task-is-throwing-deadlock-error – user4912134 Dec 01 '21 at 17:33