java 执行ssis包_在SSIS包中使用CHECKPOINT重新启动包执行 - Go语言中文社区

java 执行ssis包_在SSIS包中使用CHECKPOINT重新启动包执行


java 执行ssis包

In the article, SQL Server CHECKPOINT, Lazy Writer, Eager Writer and Dirty Pages in SQL Server, we talked about the CHECKPOINT process for SQL Server databases. This article is about CHECKPOINT in SSIS package.

SQL ServerSQL Server CHECKPOINT,惰性编写器,Eager Writer和脏页一文中 ,我们讨论了SQL Server数据库的CHECKPOINT流程。 本文是关于SSIS包中的CHECKPOINT的。

  • Note: Before reading this article, let me just tell you that CHECKPOINT in SSIS package and SQL Server CHECKPOINT are entirely different terms and are not related in any way. 注意:在阅读本文之前,让我只告诉您SSIS包中的CHECKPOINT和SQL Server CHECKPOINT是完全不同的术语,并且没有任何关系。

介绍 (Introduction)

Suppose we have an integration service package that does lots of data transformations and data insertion. The SSIS package fails, and you identify the error following the article Overview of SSIS Package Logging. You fix the error and rerun the package.

假设我们有一个集成服务包,它可以进行大量的数据转换和数据插入。 SSIS软件包失败,您可以在文章SSIS软件包日志概述下找到错误。 您修复该错误,然后重新运行该程序包。

Suppose we have 10 steps in the package and it failed after completing 7 steps. If we restart the package, it starts from step 1 and runs the whole package. Assume that overall package execution takes 5 hours to complete and out of which step 1 to 6 takes most of the time approx. 4 hours. Steps 7 to 10 only takes 1 hour. The package failed at step 7 that shows we have already executed it for approximately 4 hours and due to an error, we need to again wait for approximately 5 hours to finish it. It is a critical package, and we cannot afford such failures. In case of failure also, we want to restart the package from the point of failure.

假设程序包中有10个步骤,并且在完成7个步骤后失败了。 如果我们重新启动程序包,它将从步骤1开始并运行整个程序包。 假设整个程序包执行需要5个小时才能完成,而步骤1到6花费了大部分时间。 4个小时。 步骤7到10仅需1个小时。 程序包在步骤7失败,表明我们已经执行了大约4个小时,并且由于错误,我们需要再次等待大约5个小时才能完成。 这是至关重要的一揽子计划,我们无法承担这样的失败。 同样在发生故障的情况下,我们希望从故障点重新启动软件包。

Do you think we can restart SSIS package from the point of failure instead of running complete package?

您认为我们可以从故障的角度重新启动SSIS软件包,而不是运行完整的软件包吗?

The answer is yes, we can use SSIS CHECKPOINT to do this task for us. Let’s explore this term in the upcoming section.

答案是肯定的,我们可以使用SSIS CHECKPOINT为我们完成此任务。 让我们在接下来的部分中探讨这个术语。

SSIS包中的CHECKPOINT概述 (Overview of CHECKPOINT in SSIS package)

We can configure a CHECKPOINT file in the SSIS package to log package execution information in it. If the package execution fails, SSIS uses the information in the checkpoint file to restart it from the point of failure. Once the package successfully executes, it removes the checkpoint file. On the next package execution, it does not find the checkpoint file and starts the package execution from stretch and creates a new checkpoint file.

我们可以在SSIS包中配置CHECKPOINT文件,以在其中记录包执行信息。 如果程序包执行失败,SSIS将使用检查点文件中的信息从失败点重新启动它。 包成功执行后,它将删除检查点文件。 在下一次执行程序包时,它将找不到检查点文件,而是从stretch开始执行程序包并创建一个新的检查点文件。

We can use CHECKPOINT in the SSIS package to restart the failed package, but it works on the control flow level. We cannot configure a checkpoint to start the package at the data flow level.

我们可以在SSIS包中使用CHECKPOINT来重新启动失败的包,但是它可以在控制流级别上运行。 我们无法配置检查点以在数据流级别启动程序包。

  • Note: This article assumes you have a basic understanding of SSIS packages. If not, please go through SSIS articles on SQLShack.
  • 注意:本文假定您对SSIS包有基本的了解。 如果没有,请阅读有关SQLShack的SSIS文章。

I have an SSIS package for my test environment, and it contains the following tasks in the Control flow:

我有一个用于测试环境的SSIS程序包,它在控制流中包含以下任务:

  • Data Flow Task

    数据流任务

  • Execute SQL task to update a few records

    执行SQL任务以更新一些记录

SSIS package configuration

The data flow task contains the following source to destination data transfer tasks.

数据流任务包含以下源到目标数据传输任务。

destination data transfer task

We have not done the configuration of CHECKPOINT in SSIS package. Let’s execute this package, and it should fail at Update Records task.

我们尚未在SSIS软件包中完成CHECKPOINT的配置。 让我们执行该程序包,它应该在“ 更新记录”任务时失败。

As expected, the SSIS package fails.

不出所料,SSIS包失败。

Failed SSIS package

The data flow task is completed successfully, and you can view that 6 rows transferred from source to destination table.

数据流任务已成功完成,您可以查看从源表转移到目标表的6行。

Successful package

Restart the SSIS package (press Ctrl+Shift+F5), and it starts the package again from the beginning. You get a similar output for this package once again. As the data flow task is executed again, we get duplicate data in the destination table.

重新启动SSIS程序包(按Ctrl + Shift + F5),它将从头开始重新启动程序包。 您将再次为此包获得类似的输出。 随着数据流任务再次执行,我们在目标表中获得了重复的数据。

We can avoid this situation using CHECKPOINT in SSIS package.

我们可以在SSIS包中使用CHECKPOINT来避免这种情况。

Configuring Checkpoints in SSIS

在SSIS中配置检查点 (Configuring Checkpoints in SSIS)

In the SSIS package, go to package properties using the menu bar (View -> Properties). You can also use the shortcut key F4 to open the following properties window.

在SSIS包中,使用菜单栏转到包属性(“视图”->“属性”)。 您也可以使用快捷键F4打开以下属性窗口。

SSIS package properties

In these properties, you can see a tab Checkpoints with following configurations:

在这些属性中,您可以看到带有以下配置的“检查点”选项卡:

  • CheckpointFileName: It is the file in which the SSIS package will log package execution information. You can click on it and browse to the destination path or paste the folder location along with file name in XML format. It should be a valid directory, and you can use a network UNC path as well, but the appropriate permissions should be set else you get an error message that the package could not access the checkpoint file CheckpointFileName :SSIS包将在其中记录包执行信息的文件。 您可以单击它并浏览到目标路径,或者将文件夹位置以及文件名粘贴为XML格式。 它应该是有效目录,并且您也可以使用网络UNC路径,但是应该设置适当的权限,否则会收到错误消息,指出程序包无法访问检查点文件
  • CheckpointUsage: It gives the following checkpoint file usage options CheckpointUsage :它提供以下检查点文件使用选项
    • Never: SSIS package will never use the checkpoint feature. It is the default option 从不 :SSIS程序包将永远不会使用检查点功能。 这是默认选项
    • IfExists: In this option, the SSIS package will read the information in the checkpoint file if it is already there. If not, it will skip this and restart the package. We should use this option in most cases IfExists :在此选项中,SSIS包将读取检查点文件中的信息(如果已存在)。 如果没有,它将跳过此步骤并重新启动软件包。 在大多数情况下,我们应该使用此选项
    • Always: We can configure the package to 始终:我们可以将包配置为Always use checkpoint information from the checkpoint file. If the information is not available, the SSIS package will throw an error message 始终使用检查点文件中的检查点信息。 如果该信息不可用,SSIS程序包将引发错误消息
  • SaveCheckpoints: We can choose to save the checkpoint information or not SaveCheckpoints:我们可以选择是否保存检查点信息

Let’s do the following CHECKPOINT in SSIS package configuration:

让我们在SSIS包配置中执行以下CHECKPOINT:

  • Checkpointusage – IfExists

    检查点使用– IfExists

  • SaveCheckpoints: True

    保存检查点:正确

CHECKPOINT option

Execute the package, and it will fail against, but we do not see the checkpoint file in the configured path. In the Execution Results tab, we get the following message.

执行该程序包,它将失败,但是在配置的路径中看不到检查点文件。 在执行结果选项卡中,我们收到以下消息。

  • Warning: This task or container has failed, but because FailPackageOnFailure property is FALSE, the package will continue. This warning is posted when the SaveCheckpoints property of the package is set to TRUE, and the task or container fails.
  • 警告:此任务或容器已失败,但是由于FailPackageOnFailure属性为FALSE,因此程序包将继续。 当程序包的SaveCheckpoints属性设置为TRUE,并且任务或容器失败时,将发布此警告。

We are also required to configure a property FailPackgaeOnFailure for all control flow tasks. Select the control flow tasks and change the value of FailPackgaeOnFailure to True.

我们还需要为所有控制流任务配置属性FailPackgaeOnFailure 。 选择控制流任务,并将FailPackgaeOnFailure的值更改为True。

FailPackgaeOnFailure property in SSIS package

Execute the package, and you can see a checkpoint file in the configured path. Open the file, and you can see the content of this file as follows.

执行该程序包,您可以在配置的路径中看到一个检查点文件。 打开文件,您可以看到该文件的内容,如下所示。

Fix the error message and rerun the package. It should only run the failed task. Package executes successfully, and you can note that it only executed the Update Records task. The data flow task was successful previously. Therefore, you do not see any status for the Data flow task because it is not executed this time.

修复错误消息,然后重新运行程序包。 它应该只运行失败的任务。 包成功执行,您可以注意到它仅执行了Update Records任务。 数据流任务先前已成功。 因此,您不会看到数据流任务的任何状态,因为这次没有执行。

Execute package with CHECKPOINT file

Go back to the location of CHECKPOINT in SSIS package file, and you will not find the file. The SSIS package removes this file once the package execution completes successfully.

回到SSIS包文件中CHECKPOINT的位置,您将找不到该文件。 包执行成功完成后,SSIS包将删除此文件。

Let’s look at one more failure example. I modified my SSIS package to include the following in the data flow task. It includes two tasks for transferring data from source to destination tables.

让我们再看一个失败示例。 我修改了SSIS包,以将以下内容包括在数据流任务中。 它包括将数据从源表传输到目标表的两项任务。

Add a new data flow task in SSIS package

I also modified the control flow task to execute the Update Record task first and then it should run the data flow task. You can see the following modified SSIS package.

我还修改了控制流任务以首先执行Update Record任务,然后它应该运行数据流任务。 您可以看到以下修改后的SSIS包。

Modified Control flow task

Once we execute the package, it should fail one of the data flow tasks. We already have CHECKPOINT in SSIS package configuration for this package.

一旦执行了程序包,它将使数据流任务之一失败。 我们已经在此包的SSIS包配置中拥有CHECKPOINT。

Failed SSIS package

Double-click on this data flow task, and it shows the second task as failed.

双击此数据流任务,它将第二个任务显示为失败。

View the failed task

You can also see a checkpoint file, and it has the following contents in it.

您还可以看到一个检查点文件,其中包含以下内容。

In the Progress bar, we also see information about the checkpoint file.

在进度栏中,我们还会看到有关检查点文件的信息。

Fix the error and execute the package again. Before the execution, what do you think will happend?

解决错误,然后再次执行程序包。 在执行之前,您认为会发生什么?

Will the package execute only the failed task in the data flow task, or will it execute both tasks inside the data flow task?

程序包将只执行数据流任务中失败的任务,还是只执行数据流任务中的两个任务?

As specified previously, CHECKPOINT in SSIS package works on the control flow level. We cannot configure it to execute the individual task at the data flow level.

如前所述,SSIS包中的CHECKPOINT在控制流级别上起作用。 我们无法将其配置为在数据流级别执行单个任务。

Let’s execute the package and note the behaviors in the package.

让我们执行该程序包并注意该程序包中的行为。

翻译自: https://www.sqlshack.com/using-checkpoint-in-ssis-package-to-restart-package-execution/

java 执行ssis包

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/culuo4781/article/details/107626367
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-06-26 17:14:59
  • 阅读 ( 637 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢