简体   繁体   English

父子程序包中的事务控制

[英]transaction control in parent child packages ssis

I have parent package in which i have foreach loop for counting flat files and within it i process each file one by one while calling(Exec package task) child package where i have sequence container. 我有一个父包,其中有foreach循环用于计数平面文件,并且在其中调用(Exec包任务)子包(其中有序列容器)时,我逐个处理每个文件。 While in child package sequence container i have two flow tasks -one is for deleting data from import schema tables and import all data from flat file into it which is passed by parent package. 在子程序包序列容器中,我有两个流程任务-一个任务是从导入模式表中删除数据,并将所有数据从平面文件导入到父程序包传递的平面文件中。 -second is moving new and updated rows from import schema to the relative staging schema tables. -second正在将新行和更新行从导入模式移到相对的阶段模式表。

Now i set "required" transaction property for parent control flow while all other components in it are "supported". 现在,我为父控件流程设置了“必需”事务属性,而其中的所有其他组件都得到了“支持”。 and set "supported" transaction property for child control flow and same for all components in it. 并为子控制流及其所有组件设置“支持的”交易属性。 So when i execute the parent package it stuck at second flow task in the child package. 因此,当我执行父程序包时,它停留在子程序包中的第二个流程任务上。

I want to rollback all transactions if any failure or error occur in any pacakge. 如果任何包装中发生任何故障或错误,我想回滚所有事务。

Please any help will be great. 请任何帮助将是巨大的。

If SSIS transactions are not working for you, consider re-architecting the package design. 如果SSIS事务对您不起作用,请考虑重新设计包装设计。 Is it possible to break up the steps and stage data multiple times before finally committing it to the end result table. 在最终将数据提交到最终结果表之前,是否有可能将步骤分多次进行阶段操作。

I honestly never use transactions. 老实说,我从不使用交易。 For an ETL process I break it out into 4 separate areas of concern: 对于ETL流程,我将其分为四个独立的关注领域:

  1. Extract - Gets data as-is from source and physically stages it in a table. 提取-从源按原样获取数据并将其物理分段在表中。 The staging table will look exactly like the source table. 登台表将看起来与源表完全一样。 This minimizes interruption with locking in the source system. 这样可以最大程度地减少因锁定源系统而造成的中断。
  2. Cleanse - Cleanses the data in place without consideration to other tables. 清理-在不考虑其他表的情况下清理到位的数据。 Cleansing can be performed in a view or with a separate package which stages the data. 可以在视图中或使用暂存数据的单独程序包执行清理。
  3. Conform - Puts data from multiple sources into one table. 符合-将来自多个源的数据放入一个表中。 This table will look like target table (ie fact, dimension) 该表将看起来像目标表(即事实,维度)
  4. Load - Loads into the end result table, is only concerned with loading to minimize interruption to access of the table to end users. 加载-加载到最终结果表中,仅与加载有关,以最大程度地减少最终用户对该表的访问中断。

I build in restartability to the packages so that if they have made it through the first few steps, they do not need to start over. 我建立了软件包的可重新启动性,因此,如果他们通过前几个步骤完成了安装,则无需重新开始。 They can pick up where they left off and finish the ETL process. 他们可以从停下来的地方接机,并完成ETL过程。

If I had multiple files to extract from, I would build a package for each. 如果我要提取多个文件,则将为每个文件构建一个程序包。 If there were a series of files with the same schema that needed to be looped through. 是否需要循环浏览具有相同架构的一系列文件。 I would build the process with restartability in mind. 我会在考虑可重启性的情况下构建该过程。 That is: 那是:

  1. Truncate the staging table 截断登台表
  2. Extract into the staging table one file at a time or in parallel 一次或并行提取一个文件到暂存表中
  3. Archive the files 存档文件

If the process were to fail, in this case, we can start from the top. 如果该过程失败,在这种情况下,我们可以从头开始。 Because we are dumping the data into a staging table (which can be a heap) this can be a super fast efficient process. 因为我们将数据转储到临时表(可以是堆)中,所以这可能是超快速高效的过程。

If your main concern is that you do not want a particular end-result table in an inconsistent state, by staging the data, you can easily wrap the final insert/update process into a SQL transaction. 如果您主要担心的是您不希望特定的最终结果表处于不一致状态,则可以通过暂存数据来轻松地将最终的插入/更新过程包装到SQL事务中。

This is pretty general advice, but the gist of it is, don't use transactions, break the process into steps and use SQL transactions where it is actually needed. 这是非常笼统的建议,但要旨是,不要使用事务,将过程分解为多个步骤,并在实际需要的地方使用SQL事务。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM