We're seeing a bizarre issues in our SSIS package. We are using an HTTP connection manager in multiple script tasks running in parallel and the connections seem to be getting mismatched. Here's the basic flow.
We have 6 containers that run in parallel. Each container does the exact same work (they are copy/pasted) except we change the value of a variable representing the report to generate that is scoped to each container. The container runs a query (using a SQL connection manager defined in the package designer) and then uses a foreach container to enumerate the rows. The variables inside the foreach container are scoped to it so we don't have a scoping issue. Within the loop we write the variable values to a log table, use a script task to generate an SSRS report and then write all the data and the report to an external system. Everything is working fine except for the generation of the report.
Within the report script block we acquire a connection to a HTTP connection manager that is defined in the package (just like the SQL connection manager). We then create a new HttpClientConnection with it and update the URL to include the necessary parameters that SSRS needs to generate the report. We then download the results and return it back to the container. Here's the basic code we use
var httpConn = Dts.Connections["ReportServerUrl"]; var clientConn = new HttpClientConnection(httpConn.AcquireConnection(null)); var uri = new UriBuilder(clientConn.ServerURL) { Query = reportQueryInfo }; clientConn.ServerURL = uri.Uri.ToString(); clientConn.DownloadData();
The issue we are seeing is that when 2 of the scripts run at the same time the ServerURLs are getting cross wired such that we see 2 of the same report being requested rather than 1 of each type that we had requested (based upon the SSRS execution logs). It's almost like we are getting a shared HTTP client connection. Provided the scripts don't run at the same time everything works correctly. We are confident our variables are set correctly because we are storing them both before and after in external tables and they are always correct. The URL calculation logic is also correct because this problem only occurs when 2 requests are sent in parallel.
What am I missing here?
Michael Taylor
http://blogs.msmvps.com/p3net