Release Lock on variables used in Execute Process Task | SSIS

与世无争的帅哥 提交于 2019-12-10 18:05:36

问题


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 ?


回答1:


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

  • http://www.sqlis.com/sqlis/post/A-deadlock-was-detected-while-trying-to-lock-variables-in-SSIS.aspx
  • http://sqlblogcasts.com/blogs/mohitnayyar/archive/2007/09/23/update-ssis-deadlock-was-detected-while-trying-to-lock-variables-mohit-nayyar.aspx


来源:https://stackoverflow.com/questions/44453384/release-lock-on-variables-used-in-execute-process-task-ssis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!