Hello all,
I'm at a loss with an SSIS package I inherited. It contains:
- 1 Script Task
- 3 Execute SQL tasks
- 5 Data flow tasks (each contains a number of merges, lookups, data inserts and other transformations)
- 1 file system task of the package.
All of these are encapsulated in a Foreach loop container. I've been tasked with modifying the package so that if any of the steps within the control/data flow fails, the entire thing
is rolled back. Now I've tried two different approaches to accomplish this:
I. Using Distributed Transactions.
I ensured that:
- MSDTC was running on target server and executing client (screenshot enclosed)
- msdtc.exe was added as an exception to server and client firewall
- Inbound and outbound rules were set for both server and client to allow DTC connections.
- ForeachLoop Container TrasanctionLevel: Required
- All other tasks TransactionLevel: Supported
- My OLEDB Connection has RetainSameConnection set to TRUE and I'm using SQL Server Authentication with Save Password checked
When I execute the package, it fails right after the script task (first step) with the following message:
[Execute SQL Task] Error: Failed to acquire connection "NHS". Connection may not be configured correctly or you may not have the right permissions on
this connection.
Task Get BatchNo From FileControl failed
Information: Aborting the current distributed transaction.
Finished, 3:07:45 PM, Elapsed time: 00:00:35.985
Warning: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum
allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Finished, 3:07:45 PM, Elapsed time: 00:00:37.109
[Connection manager "NHS"] Error: The SSIS Runtime has failed to enlist the OLE DB connection in a distributed transaction with error 0x8004D00E "The
transaction has already been implicitly or explicitly committed or aborted".
[Connection manager "NHS"] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x8004D00E.
Warning: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum
allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Finished, 3:07:45 PM, Elapsed time: 00:00:37.328
II. After spending an entire week trying to figure out a workaround, I decided to try SQL Tasks to try to accomplish my goa using 3 Execute SQL Tasks:
- BEGIN TRAN before the foreach loop container
- COMMIT TRAN After the ForeachLoop Container with a Success Constraint
- ROLLBACK TRAN After the ForeachLoop Container with a Failure constraint
In this case, foreachloop container and all other tasks have TransactionLevel property set to Supported. Now here, the problem is that the package executes up to the fourth data flow task
and hangs there forever. After logging into SQL Server and verifying the running sessions, I noticed sys.sp_describe_first_result_set;1 as a headblocker session. Doing some research, I found it could be related to a few TRUNCATE statements in some of my Data
flow tasks which could cause a schema lock. I went ahead and changed the ValidateExternalMetaData property to False for all tasks within my data flow and changed my truncate statements to DELETE statements instead. Re-ran package and still hangs in the same
spot with the same headblocker. As an alternative, I tried creating a second OLEDB connection to the same database, assigned that new OLEDB Connection to my BEGIN, ROLLBACK and COMMIT SQL tasks with RetainSameConnectionProperty set to TRUE and changed the
RetainSameConnectionProperty to FALSE (and tried it with TRUE as well) in the original OLEDB connection (the one used by the data flow tasks). This worked in the sense that the package appeared to execute (It ran and Commit Tran executed fine) and then I ran
it again with a forced error to cause it to fail and the Rollback TRAN task executed successfully, however, when I queried the affected tables, the transaction hadn't rolled back, all new records were inserted and old ones were updated (the begin tran was
clearly started in a different connection and hence didn’t affect the package’s
workflow).
I'm not sure what else to try at this point. Any help would be truly appreciated, I’m about
to go nuts with this!
P.S. additionally, all objects have "DelayValidation" set to true on everything and the SQL Server is 2012.