Home
%3CLINGO-SUB%20id%3D%22lingo-sub-964881%22%20slang%3D%22en-US%22%3EBest%20practice%20recommendation%20for%20SSIS%20package%20execution%20retries%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-964881%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1850653435%22%20id%3D%22toc-hId-1850653435%22%3ETransient%20issues%3C%2FH2%3E%0A%3CP%3EYour%20typical%20SSIS%20package%20often%20needs%20to%20access%20external%20resources%2C%20like%20databases%2C%20files%2C%20or%20services.%20If%20your%20package%20execution%20and%20those%20resources%20are%20in%20the%20same%20on-premises%20environment%20managed%20by%20yourself%2C%20the%20execution%20should%20be%20completed%20without%20any%20issue.%20%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EHowever%2C%20if%20your%20package%20execution%20and%2For%20some%20of%20those%20resources%20are%20in%20a%20cloud%20environment%2C%20e.g.%20running%20your%20package%20on%20SSIS%20Integration%20Runtime%20(IR)%20in%20in%20Azure%20Data%20Factory%20(ADF)%2C%20sometimes%20the%20execution%20fails%20due%20to%20transient%20network%2Fthird-party%20service%20related%20issues%3C%2FFONT%3E.%20You%20can%20learn%20more%20about%20them%20here.%20These%20issues%20might%20disappear%20by%20retrying%20your%20package%20execution.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--701503526%22%20id%3D%22toc-hId--701503526%22%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3ERecommended%20solutions%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3ETo%20ensure%20the%20completion%20of%20your%20package%20execution%20and%20avoid%20its%20repetitive%20manual%20invocations%2C%20you%20can%20configure%20it%20to%20retry%20automatically.%20Depending%20on%20the%20logic%20of%20your%20package%2C%20you%20can%20retry%20its%20execution%20completely%20or%20partially%2C%20but%20please%20be%20aware%20that%20package%20execution%20retries%20can%20only%20solve%20transient%20issues.%20Effective%20package%20execution%20retries%20depend%20on%20a%20suitable%20retry%20count%20and%20interval.%20Too%20small%20a%20retry%20count%20might%20not%20be%20sufficient%20to%20complete%20the%20package%20execution.%20Too%20big%20a%20retry%20count%20and%20too%20short%20a%20retry%20interval%20might%20occupy%20resources%20and%20block%20their%20usage%20for%20extended%20periods%20of%20time.%20Depending%20on%20your%20package%20execution%20scenario%2C%20there%20are%20many%20retry%20options%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EIf%20your%20package%20execution%20can%20be%20retried%20directly%2C%20where%20the%20next%20execution%20won%E2%80%99t%20be%20impacted%20by%20previous%20failure%3A%3COL%20style%3D%22list-style-type%3A%20lower-alpha%3B%22%3E%0A%3CLI%3EIf%20you%20use%20T-SQL%20to%20run%20your%20package%2C%20see%20%3CSTRONG%3ERetry%20package%20executions%20via%20T-SQL%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EIf%20you%20use%20Execute%20SSIS%20Package%20activity%20in%20ADF%20pipeline%20to%20run%20your%20package%2C%20see%20%3CSTRONG%3ERetry%20Execute%20SSIS%20Package%20activity%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EIf%20you%20use%20Stored%20Procedure%20activity%20in%20ADF%20pipeline%20to%20run%20your%20package%2C%20see%20%3CSTRONG%3ERetry%20package%20executions%20via%20Stored%20Procedure%20activity%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EIf%20your%20package%20execution%20requires%20some%20preparations%2C%20like%20cleaning%20up%20dirty%20data%2C%20before%20it%20can%20be%20retried%3A%3COL%20style%3D%22list-style-type%3A%20lower-alpha%3B%22%3E%0A%3CLI%3EIf%20your%20package%20is%20editable%2C%20see%20%3CSTRONG%3ERetry%20preparations%20for%20editable%20packages%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EIf%20your%20package%20is%20non-editable%3A%3COL%20style%3D%22list-style-type%3A%20lower-roman%3B%22%3E%0A%3CLI%3EIf%20you%20use%20T-SQL%20to%20run%20your%20package%2C%20see%20%3CSTRONG%3ERetry%20preparations%20for%20non-editable%20packages%20via%20T-SQL%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EIf%20you%20use%20Execute%20SSIS%20Package%2FStored%20Procedure%20activity%20in%20ADF%20pipeline%20to%20run%20your%20package%2C%20see%20%3CSTRONG%3ERetry%20preparations%20for%20non-editable%20packages%20in%20ADF%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%203.%20If%20you%20want%20to%20partially%20retry%20your%20package%20execution%2C%20see%20%3CSTRONG%3ERetry%20package%20executions%20partially%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1041306809%22%20id%3D%22toc-hId-1041306809%22%3ERetry%20package%20executions%20via%20T-SQL%3C%2FH2%3E%0A%3CP%3EYou%20can%20use%20built-in%20SSISDB%20stored%20procedures%20to%20trigger%20package%20executions.%20The%20%3CEM%3E%5Bcatalog%5D.%5Bstart_execution%5D%3C%2FEM%3E%20stored%20procedure%20accepts%20an%20argument%20called%20%3CEM%3E%40retry_count%3C%2FEM%3E%20to%20specify%20the%20maximum%20number%20of%20retries%20for%20your%20package%20execution.%20Its%20default%20value%20is%200%2C%20which%20means%20not%20to%20retry%2C%20so%20you%20can%20assign%20different%20values%20to%20retry%20your%20package%20execution%20automatically%20when%20it%20fails.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EDeclare%20%40execution_id%20bigint%0AEXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bcreate_execution%5D%20%40package_name%3DN'%3CPACKGE%20name%3D%22%22%3E'%2C%0A%20%20%20%20%20%20%20%40execution_id%3D%40execution_id%20OUTPUT%2C%0A%20%20%20%20%20%20%20%40folder_name%3DN'%3CFOLDER%20name%3D%22%22%3E'%2C%0A%20%20%20%20%20%20%20%40project_name%3DN'%3CPROJECT%20name%3D%22%22%3E'%2C%0A%20%20%20%20%20%40use32bitruntime%3DFalse%2C%0A%20%20%20%20%20%20%20%40reference_id%3DNull%0ADeclare%20%40retry_count%20int%20%3D%205%0AEXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bstart_execution%5D%20%40execution_id%20%2C%0A%20%20%20%20%20%20%20%40retry_count%3D%40retry_count%3C%2FPROJECT%3E%3C%2FFOLDER%3E%3C%2FPACKGE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152289i4BE803517DC505B4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EHere%20we%E2%80%99ve%20set%20%3CEM%3E%40retry_count%3C%2FEM%3E%20to%205%20and%20the%20execution%20report%20on%20SSMS%20shows%20%3CEM%3EExecuted%20Count%3C%2FEM%3E%20to%20be%206%2C%20which%20means%20after%20the%20first%20failed%20package%20execution%2C%20it%E2%80%99s%20automatically%20retried%20another%205%20times.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1510850152%22%20id%3D%22toc-hId--1510850152%22%3ERetry%20Execute%20SSIS%20Package%20activity%3C%2FH2%3E%0A%3CP%3EYou%20can%20use%20Execute%20SSIS%20Package%20activity%20in%20ADF%20pipeline%20to%20trigger%20package%20executions%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fhow-to-invoke-ssis-package-ssis-activity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERun%20SSIS%20packages%20with%20Execute%20SSIS%20Package%20activity%3C%2FA%3E.%20ADF%20provides%20a%20built-in%20feature%20to%20retry%20activities%20with%202%20properties%2C%20%3CEM%3ERetry%3C%2FEM%3E%20and%20%3CEM%3ERetry%20interval%3C%2FEM%3E%20(in%20seconds)%2C%20which%20allow%20you%20to%20configure%20the%20maximum%20retry%20count%20and%20interval%20between%20each%20retry.%20You%20can%20find%20them%20in%20%3CEM%3EGeneral%3C%2FEM%3E%20tab%20of%20Execute%20SSIS%20Package%20activity.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152290i2C8B8D683F3FE4CB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152291iF478182C228805F2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_2.png%22%20title%3D%22clipboard_image_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EHere%20ADF%20UI%20shows%204%20execution%20records%20that%20can%20also%20be%20found%20in%20SSMS%2C%20which%20means%20after%20the%20first%20failed%20Execute%20SSIS%20Package%20activity%2C%20it%E2%80%99s%20automatically%20retried%20another%203%20times%20with%2030%20seconds%20interval%20between%20each%20retry.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-231960183%22%20id%3D%22toc-hId-231960183%22%3ERetry%20package%20executions%20via%20Stored%20Procedure%20activity%3C%2FH2%3E%0A%3CP%3EYou%20can%20also%20use%20Stored%20Procedure%20activity%20in%20ADF%20pipeline%20to%20trigger%20package%20executions%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fhow-to-invoke-ssis-package-stored-procedure-activity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERun%20SSIS%20packages%20with%20Stored%20Procedure%20activity%3C%2FA%3E.%20With%20this%20activity%2C%20you%20have%20two%20methods%20to%20retry%20your%20package%20execution%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EBuilt-in%20activity%20retry.%20Similar%20to%20Execute%20SSIS%20Package%20activity%20(see%20above)%20and%20other%20ADF%20activities%2C%20you%20can%20use%20the%20%3CEM%3ERetry%3C%2FEM%3E%20and%20%3CEM%3ERetry%20interval%3C%2FEM%3E%20properties%20in%20%3CEM%3EGeneral%3C%2FEM%3E%20tab.%20For%20example%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152293iB2A60DD723620098%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_3.png%22%20title%3D%22clipboard_image_3.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152294iD89DAA3561704504%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_4.png%22%20title%3D%22clipboard_image_4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3ERetry%20argument%20in%20SSISDB%20stored%20procedure.%20As%20already%20mentioned%20in%20%3CSTRONG%3ERetry%20package%20executions%20via%20T-SQL%26nbsp%3B%3C%2FSTRONG%3E%20(see%20above)%2C%20you%20can%20use%20the%20%3CEM%3E%40retry_count%3C%2FEM%3E%20argument.%20For%20example%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EDECLARE%20%40return_value%20INT%2C%20%40exe_id%20BIGINT%2C%20%40err_msg%20NVARCHAR(150)%20%20%20EXEC%20%40return_value%3D%5BSSISDB%5D.%5Bcatalog%5D.%5Bcreate_execution%5D%20%40folder_name%3DN'retry'%2C%20%40project_name%3DN'Retry'%2C%20%40package_name%3DN'RetryNumber.dtsx'%2C%20%40use32bitruntime%3D0%2C%20%40runinscaleout%3D1%2C%20%40useanyworker%3D1%2C%20%40execution_id%3D%40exe_id%20OUTPUT%20%20%20EXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bset_execution_parameter_value%5D%20%40exe_id%2C%20%40object_type%3D50%2C%20%40parameter_name%3DN'SYNCHRONIZED'%2C%20%40parameter_value%3D1%20%20%20EXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bstart_execution%5D%20%40execution_id%3D%40exe_id%2C%20%40retry_count%3D0%20%20%20IF(SELECT%20%5Bstatus%5D%20FROM%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bexecutions%5D%20WHERE%20execution_id%3D%40exe_id)%26lt%3B%26gt%3B7%20BEGIN%20SET%20%40err_msg%3DN'Your%20package%20execution%20did%20not%20succeed%20for%20execution%20ID%3A%20'%20%2B%20CAST(%40exe_id%20AS%20NVARCHAR(20))%20RAISERROR(%40err_msg%2C15%2C1)%20END%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20two%20retry%20methods%20differ%20as%20follows%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EUsing%20the%20activity%20retry%20will%20generate%20multiple%20activity%20runs%2C%20while%20using%20the%20retry%20argument%20will%20only%20generate%20one%20activity%20run.%3C%2FLI%3E%0A%3CLI%3EYou%20can%20set%20a%20retry%20interval%20when%20using%20the%20activity%20retry%2C%20but%20not%20when%20using%20the%20retry%20argument.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH2%20id%3D%22toc-hId-1974770518%22%20id%3D%22toc-hId-1974770518%22%3ERetry%20preparations%20for%20editable%20packages%3C%2FH2%3E%0A%3CP%3EIn%20some%20cases%2C%20a%20failed%20package%20execution%20can%E2%80%99t%20be%20retried%20immediately%2C%20so%20you%20need%20to%20do%20some%20preparations%20before%20retrying%20it.%20If%20your%20package%20is%20editable%2C%20you%20can%20open%20it%20in%20SSDT%20and%20add%20preparation%20tasks%20you%20need%20at%20the%20beginning%20of%20its%20Control%20Flow.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152292i91069D8CCF0B6B5D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_5.png%22%20title%3D%22clipboard_image_5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20a%20Script%20Task%20(%3CEM%3EDo%20preparation%3C%2FEM%3E%20in%20the%20above%20package%20example)%20to%20clean%20dirty%20data%2C%20create%2Fdelete%20tables%2C%20or%20do%20anything%20else%20upstream%20to%20prepare%20for%20the%20following%20downstream%20tasks%2C%20ensuring%20that%20your%20package%20is%20retriable.%20Afterwards%2C%20you%20can%20follow%20the%20above%20%3CSTRONG%3ERetry%20package%20executions%20via%20T-SQL%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ERetry%20Execute%20SSIS%20Package%20activity%3C%2FSTRONG%3E%2C%20or%20%3CSTRONG%3ERetry%20package%20executions%20via%20Stored%20procedure%20activity%3C%2FSTRONG%3E%20sections%20to%20retry%20your%20package%20execution%20automatically.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--577386443%22%20id%3D%22toc-hId--577386443%22%3ERetry%20preparations%20for%20non-editable%20packages%20via%20T-SQL%3C%2FH2%3E%0A%3CP%3EIf%20you%E2%80%99re%20using%20T-SQL%20to%20run%20your%20package%20and%20it%20isn%E2%80%99t%20editable%2C%20you%20can%20use%20a%20loop%20in%20T-SQL%20to%20prepare%20and%20retry%20its%20execution.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EDeclare%20%40max_retry_count%20int%20%3D%203%0ADeclare%20%40retry_interval%20nvarchar(10)%20%3D%20N'00%3A00%3A30'%0A%20%0ADeclare%20%40exec_count%20int%20%3D%200%0AWHILE%20%40exec_count%20%26lt%3B%3D%20%40max_retry_count%0ABEGIN%0A%20%20%20%20%20%20%20--%20Do%20anything%20here%20to%20prepare%20execution%0A%20%20%20%20%20%20%20--%20Example%3A%20clean%20tmp%20table%0A%20%20%20%20%20%20%20--%20truncate%20table%20%5Bexample%5D.%5Btmp%5D%0A%20%0A%20%20%20%20%20%20%20--%20Create%20executoin%0A%20%20%20%20%20%20%20Declare%20%40execution_id%20bigint%0A%20%20%20%20%20%20%20EXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bcreate_execution%5D%20%40package_name%3DN'%3CPACKAGE%20name%3D%22%22%3E'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40execution_id%3D%40execution_id%20OUTPUT%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40folder_name%3DN'%3CFOLDER%20name%3D%22%22%3E'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40project_name%3DN'%3CPROJECT%20name%3D%22%22%3E'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%40use32bitruntime%3DFalse%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40reference_id%3DNull%0A%20%0A%20%20%20%20%20%20%20SELECT%20%40execution_id%0A%20%20%20%20%20%20%20--%20Wait%20until%20package%20execution%20is%20done%0A%20%20%20%20%20%20%20EXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bset_execution_parameter_value%5D%20%40execution_id%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40object_type%3D50%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40parameter_name%3DN'SYNCHRONIZED'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40parameter_value%3D%201%0A%20%0A%20%20%20%20%20%20%20--%20Start%20execution%0A%20%20%20%20%20%20%20EXEC%20%5BSSISDB%5D.%5Bcatalog%5D.%5Bstart_execution%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%40execution_id%0A%20%0A%20%20%20%20%20%20%20--%20Check%20execution%20result%0A%20%20%20%20%20%20%20Declare%20%40exec_status%20int%0A%20%20%20%20%20%20%20SELECT%20%40exec_status%20%3D%20status%20from%20%5Bcatalog%5D.%5Bexecutions%5D%20where%20execution_id%20%3D%20%40execution_id%0A%20%0A%20%20%20%20%20%20%20--%20Check%20execution%20status%20to%20determine%20end%20execution%20or%20retry%0A%20%20%20%20%20%20%20IF%20%40exec_status%20%3D%204%0A%20%20%20%20%20%20%20BEGIN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20SET%20%40exec_count%20%3D%20%40exec_count%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20IF%20%40exec_count%20%26lt%3B%3D%20%40max_retry_count%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20BEGIN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20WAITFOR%20DELAY%20%40retry_interval%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20END%0A%20%20%20%20%20%20%20END%0A%20%20%20%20%20%20%20ELSE%0A%20%20%20%20%20%20%20BEGIN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20SET%20%40exec_count%20%3D%20%40max_retry_count%20%2B%201%0A%20%20%20%20%20%20%20END%0AEND%3C%2FPROJECT%3E%3C%2FFOLDER%3E%3C%2FPACKAGE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20the%20beginning%20of%20the%20loop%2C%20you%20can%20do%20anything%20to%20prepare%20for%20your%20package%20execution.%20After%20your%20preparations%2C%20you%20can%20use%20%3CEM%3ESYNCHRONIZED%3C%2FEM%3E%20parameter%20to%20ensure%20that%20SSISDB%20stored%20procedure%20waits%20until%20your%20package%20execution%20is%20completed%2C%20so%20you%20can%20get%20its%20resulting%20status%20to%20determine%20whether%20to%20retry%20it%20or%20not.%20If%20its%20status%20is%20failed%20(%3D%204)%2C%20you%20can%20wait%20for%20your%20specified%20interval%20and%20then%20retry%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1165423892%22%20id%3D%22toc-hId-1165423892%22%3ERetry%20preparations%20for%20non-editable%20packages%20in%20ADF%3C%2FH2%3E%0A%3CP%3EIf%20you%E2%80%99re%20using%20Execute%20SSIS%20Package%20activity%20in%20ADF%20pipeline%20to%20run%20your%20package%20and%20it%20isn%E2%80%99t%20editable%2C%20you%20can%20use%20another%20ADF%20activity%20to%20prepare%20for%20its%20execution%20in%20the%20same%20pipeline.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152295i65E00F1A33A877D2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_7.png%22%20title%3D%22clipboard_image_7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20Stored%20Procedure%20activity%20(%3CEM%3EDo%20preparation%3C%2FEM%3E%20in%20the%20above%20pipeline%20example)%20to%20clean%20dirty%20data%20left%20over%20by%20the%20previously%20failed%20package%20execution.%20Next%2C%20you%20can%20implement%20your%20retry%20logic%20programmatically%20using%20the%20framework%20of%20your%20choice%2C%20such%20as%20.NET%2C%20to%20run%20your%20pipeline%2C%20monitor%20its%20result%2C%20and%20rerun%20it%20if%20Execute%20SSIS%20Package%20activity%20fails.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Eint%20maxRetryCount%20%3D%203%3B%0ATimeSpan%20retryIntervalInSecond%20%3D%20TimeSpan.FromSeconds(30)%3B%0ATimeSpan%20checkStatusIntervalInSecond%20%3D%20TimeSpan.FromSeconds(5)%3B%0A%20%0Aint%20execCount%20%3D%200%3B%0Awhile%20(execCount%20%26lt%3B%3D%20maxRetryCount)%0A%7B%0A%20%20%20%2F%2F%20Create%20a%20pipeline%20run%0A%20%20%20Console.WriteLine(%22Creating%20pipeline%20run...%22)%3B%0A%20%20%20CreateRunResponse%20runResponse%20%3D%20client.Pipelines.CreateRunWithHttpMessagesAsync(%0A%20%20%20%20%20%20%20resourceGroup%2C%20dataFactoryName%2C%20pipelineName%0A%20%20%20).Result.Body%3B%0A%20%20%20Console.WriteLine(%22Pipeline%20run%20ID%3A%20%22%20%2B%20runResponse.RunId)%3B%0A%20%0A%20%20%20%2F%2F%20Monitor%20and%20wait%20for%20pipeline%20finish%0A%20%20%20Console.WriteLine(%22Checking%20pipeline%20run%20status...%22)%3B%0A%20%20%20PipelineRun%20pipelineRun%3B%0A%20%20%20while%20(true)%0A%20%20%20%7B%0A%20%20%20%20%20%20%20pipelineRun%20%3D%20client.PipelineRuns.Get(%0A%20%20%20%20%20%20%20%20%20%20%20resourceGroup%2C%20dataFactoryName%2C%20runResponse.RunId)%3B%0A%20%20%20%20%20%20%20Console.WriteLine(%22Status%3A%20%22%20%2B%20pipelineRun.Status)%3B%0A%20%20%20%20%20%20%20if%20(pipelineRun.Status%20%3D%3D%20%22InProgress%22)%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20Thread.Sleep(checkStatusIntervalInSecond)%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%7D%0A%20%0A%20%20%20%2F%2F%20Check%20Execute%20SSIS%20package%20activity%20status%0A%20%20%20Console.WriteLine(%22Checking%20Execute%20SSIS%20activity%20run%20details...%22)%3B%0A%20%20%20RunFilterParameters%20filterParams%20%3D%20new%20RunFilterParameters(%0A%20%20%20%20%20%20%20DateTime.UtcNow.AddMinutes(-10)%2C%20DateTime.UtcNow.AddMinutes(10))%3B%0A%20%20%20ActivityRunsQueryResponse%20queryResponse%20%3D%20client.ActivityRuns.QueryByPipelineRun(%0A%20%20%20%20%20%20%20resourceGroup%2C%20dataFactoryName%2C%20runResponse.RunId%2C%20filterParams)%3B%0A%20%20%20var%20ssisActivityRun%20%3D%20queryResponse.Value.Where((run)%20%3D%26gt%3B%20run.ActivityName%20%3D%3D%20%22Execute%20SSIS%20package1%22).First()%3B%0A%20%0A%20%20%20%2F%2F%20According%20to%20Execute%20SSIS%20package%20activity%20status%2C%20decides%20to%20do%20retry%20or%20not%0A%20%20%20if%20(ssisActivityRun.Status%20%3D%3D%20%22Failed%22)%0A%20%20%20%7B%0A%20%20%20%20%20%20%20Console.WriteLine(%22Execute%20SSIS%20package%20is%20Failed.%22)%3B%0A%20%20%20%20%20%20%20execCount%2B%2B%3B%0A%20%20%20%20%20%20%20if%20(execCount%20%26lt%3B%3D%20maxRetryCount)%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20Console.WriteLine(%22Sleep%20and%20retry%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20Thread.Sleep(retryIntervalInSecond)%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%7D%0A%20%20%20else%0A%20%20%20%7B%0A%20%20%20%20%20%20%20Console.WriteLine(%22Execute%20SSIS%20package%20is%20Succeeded.%20No%20need%20to%20retry.%22)%3B%0A%20%20%20%20%20%20%20break%3B%0A%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20899px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152677iDEFA4821A0319624%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22sdkretry.PNG%22%20title%3D%22sdkretry.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1386733069%22%20id%3D%22toc-hId--1386733069%22%3ERetry%20package%20executions%20partially%3C%2FH2%3E%0A%3CP%3EIf%20only%20a%20specific%20part%20of%20your%20package%20is%20impacted%20by%20transient%20issues%20and%20you%20prefer%20to%20run%20other%20parts%20only%20once%20to%20minimize%20the%20overall%20running%20costs%2C%20then%20you%20can%20redesign%20your%20package%20to%20only%20retry%20the%20execution%20of%20that%20specific%20part.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152296i4868F5F9F9C642B7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_8.png%22%20title%3D%22clipboard_image_8.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152298i7EA96B9A66EF565B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_9.png%22%20title%3D%22clipboard_image_9.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20imagine%20a%20Data%20Flow%20task%20in%20your%20package%20that%20copies%20on-premises%20data%20to%20a%20cloud%20staging%20area%20(%3CEM%3EStaging%20Data%20Flow%3C%2FEM%3E%20in%20the%20above%20package%20example)%2C%20it%E2%80%99s%20the%20only%20part%20that%20sometimes%20fails%20due%20to%20connectivity%2Fnetwork%20issues%20and%20this%20always%20leads%20to%20a%20failure%20of%20the%20whole%20package%20execution.%20To%20avoid%20the%20complete%20failure%2C%20you%20can%20add%20a%20For%20Loop%20container%20in%20your%20package%20that%20makes%20%3CEM%3EStaging%20Data%20Flow%3C%2FEM%3E%20task%20retriable.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152299iD71E349AFA57DE93%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_10.png%22%20title%3D%22clipboard_image_10.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ETo%20implement%20your%20retry%20logic%2C%20you%20can%20first%20add%203%20user%20variables%20and%20assign%20values%20to%20them%20(%3CEM%3EStagingRetryCount%3C%2FEM%3E%2F%3CEM%3EStagingRetryIntervalInSecond%3C%2FEM%3E%2F%3CEM%3EStagingRetryMaxCount%3C%2FEM%3E%20%3CEM%3E%3D%200%2F3%2F5%3C%2FEM%3E%2C%20respectively%2C%20in%20the%20above%20example).%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152300iC6CD11E1E9F7CFC5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_11.png%22%20title%3D%22clipboard_image_11.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAfter%20adding%20a%20For%20Loop%20container%20in%20your%20Control%20Flow%2C%20you%20can%20open%20its%20Properties%20table%20and%20set%20the%20value%20of%20its%20MaximumErrorCount%20property%20to%20%3CEM%3EStagingRetryMaxCount%3C%2FEM%3E%20%2B%201%20(%3CEM%3E%3D%206%20%3C%2FEM%3Ein%20the%20above%20example)%2C%20ensuring%20that%20%3CEM%3EStaging%20Data%20Flow%3C%2FEM%3E%20task%20will%20be%20retried%20at%20most%20%3CEM%3EStagingRetryMaxCount%3C%2FEM%3E%20times.%3C%2FP%3E%0A%3CP%3EDouble-clicking%20on%20the%20For%20Loop%20container%2C%20you%20can%20open%20its%20editor%20and%20add%20an%20expression%20for%20each%20of%20its%20loop%20iteration%20properties.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152304iBDA3208EE4A3A5AE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_12.png%22%20title%3D%22clipboard_image_12.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20set%20the%20values%20for%20InitExpression%2FEvalExpression%2FAssignExpression%20properties%20as%20%3CEM%3E%40StagingRetryCount%20%3D%200%3C%2FEM%3E%2F%3CEM%3E%40StagingRetryCount%20%26lt%3B%3D%20%40StagingRetryMaxCount%3C%2FEM%3E%2F%3CEM%3E%40StagingRetryCount%20%3D%20%40StagingRetryCount%20%2B%201%3C%2FEM%3E%2C%20respectively%2C%20ensuring%20that%20the%20first%20loop%20iteration%20is%20the%20initial%20package%20execution%2C%20the%20second%20iteration%20will%20be%20the%20first%20retry%2C%20subsequent%20iterations%20will%20increment%20the%20retry%20count%2C%20and%20the%20iteration%20that%20increments%20the%20retry%20count%20beyond%20its%20maximum%20will%20be%20the%20last%20retry%2C%20so%20the%20loop%20will%20be%20exited%20after%20that.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152301i00BFB3604F35C177%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_13.png%22%20title%3D%22clipboard_image_13.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENext%2C%20you%20can%20link%20the%20Success%2FFailure%20paths%20of%20%3CEM%3EStaging%20Data%20Flow%3C%2FEM%3E%20task%20to%20Expression%2FScript%20Tasks%20(%3CEM%3EExit%20Loop%2FSleep%20Interval%3C%2FEM%3E%20in%20the%20above%20For%20Loop%20container%20example)%2C%20respectively%2C%20and%20move%20all%20tasks%20into%20the%20container.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152302i03DA593E70F7E3AA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_14.png%22%20title%3D%22clipboard_image_14.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20%3CEM%3EExit%20Loop%3C%2FEM%3E%20task%2C%20you%20can%20add%20an%20expression%20that%20sets%20%3CEM%3EStagingRetryCount%20%3C%2FEM%3Eto%20%3CEM%3EStagingRetryMaxCount%3C%2FEM%3E%2C%20so%20the%20loop%20will%20be%20exited%20immediately.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152306i261596C7CDE9AC0C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_15.png%22%20title%3D%22clipboard_image_15.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152305i1610D48AA6C68168%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_16.png%22%20title%3D%22clipboard_image_16.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20%3CEM%3ESleep%20Interval%3C%2FEM%3E%20task%2C%20you%20can%20implement%20a%20retry%20interval%20programmatically%20using%20C%23%20based%20on%20%3CEM%3EStagingRetryIntervalInSecond%3C%2FEM%3E%20variable%20to%20avoid%20network%2Fservice%20throttling.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152307i87A7FE0420240E31%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_17.png%22%20title%3D%22clipboard_image_17.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152309i49BCEF4B7F362930%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_18.png%22%20title%3D%22clipboard_image_18.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAt%20last%2C%20you%20can%20now%20link%20the%20For%20Loop%20container%20with%20upstream%2Fdownstream%20tasks%20from%20your%20original%20package%20(%3CEM%3EDo%20something%2FDo%20something%20else%20%3C%2FEM%3Ein%20the%20above%20package%20example%2C%20respectively)%2C%20such%20that%20when%20you%20run%20the%20new%20package%2C%20if%20%3CEM%3EStaging%20Data%20Flow%3C%2FEM%3E%20task%20fails%2C%20it%20will%20be%20retried%20automatically%20a%20maximum%20of%20%3CEM%3EStagingRetryMaxCount%3C%2FEM%3E%20times%20with%20an%20interval%20of%20%3CEM%3EStagingRetryIntervalInSecond%20%3C%2FEM%3Eseconds%20between%20each%20retry.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-964881%22%20slang%3D%22en-US%22%3E%3CP%3ETo%20ensure%20the%20completion%20of%20your%20package%20execution%20and%20avoid%20its%20repetitive%20manual%20invocations%2C%20you%20can%20configure%20it%20to%20retry%20automatically.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

 

Transient issues

Your typical SSIS package often needs to access external resources, like databases, files, or services. If your package execution and those resources are in the same on-premises environment managed by yourself, the execution should be completed without any issue. However, if your package execution and/or some of those resources are in a cloud environment, e.g. running your package on SSIS Integration Runtime (IR) in in Azure Data Factory (ADF), sometimes the execution fails due to transient network/third-party service related issues. You can learn more about them here. These issues might disappear by retrying your package execution.

 

Recommended solutions

To ensure the completion of your package execution and avoid its repetitive manual invocations, you can configure it to retry automatically. Depending on the logic of your package, you can retry its execution completely or partially, but please be aware that package execution retries can only solve transient issues. Effective package execution retries depend on a suitable retry count and interval. Too small a retry count might not be sufficient to complete the package execution. Too big a retry count and too short a retry interval might occupy resources and block their usage for extended periods of time. Depending on your package execution scenario, there are many retry options:

  1. If your package execution can be retried directly, where the next execution won’t be impacted by previous failure:
    1. If you use T-SQL to run your package, see Retry package executions via T-SQL 
    2. If you use Execute SSIS Package activity in ADF pipeline to run your package, see Retry Execute SSIS Package activity 
    3. If you use Stored Procedure activity in ADF pipeline to run your package, see Retry package executions via Stored Procedure activity 
  2. If your package execution requires some preparations, like cleaning up dirty data, before it can be retried:
    1. If your package is editable, see Retry preparations for editable packages
    2. If your package is non-editable:
      1. If you use T-SQL to run your package, see Retry preparations for non-editable packages via T-SQL 
      2. If you use Execute SSIS Package/Stored Procedure activity in ADF pipeline to run your package, see Retry preparations for non-editable packages in ADF

    3. If you want to partially retry your package execution, see Retry package executions partially

 

Retry package executions via T-SQL

You can use built-in SSISDB stored procedures to trigger package executions. The [catalog].[start_execution] stored procedure accepts an argument called @retry_count to specify the maximum number of retries for your package execution. Its default value is 0, which means not to retry, so you can assign different values to retry your package execution automatically when it fails. For example:

 

Declare @execution_id bigint
EXEC [SSISDB].[catalog].[create_execution] @package_name=N'<packge name>',
       @execution_id=@execution_id OUTPUT,
       @folder_name=N'<folder name>',
       @project_name=N'<project name>',
     @use32bitruntime=False,
       @reference_id=Null
Declare @retry_count int = 5
EXEC [SSISDB].[catalog].[start_execution] @execution_id ,
       @retry_count=@retry_count

 

clipboard_image_0.png

Here we’ve set @retry_count to 5 and the execution report on SSMS shows Executed Count to be 6, which means after the first failed package execution, it’s automatically retried another 5 times.

 

Retry Execute SSIS Package activity

You can use Execute SSIS Package activity in ADF pipeline to trigger package executions, see Run SSIS packages with Execute SSIS Package activity. ADF provides a built-in feature to retry activities with 2 properties, Retry and Retry interval (in seconds), which allow you to configure the maximum retry count and interval between each retry. You can find them in General tab of Execute SSIS Package activity. For example:

clipboard_image_1.pngclipboard_image_2.png

Here ADF UI shows 4 execution records that can also be found in SSMS, which means after the first failed Execute SSIS Package activity, it’s automatically retried another 3 times with 30 seconds interval between each retry.

 

Retry package executions via Stored Procedure activity

You can also use Stored Procedure activity in ADF pipeline to trigger package executions, see Run SSIS packages with Stored Procedure activity. With this activity, you have two methods to retry your package execution:

  1. Built-in activity retry. Similar to Execute SSIS Package activity (see above) and other ADF activities, you can use the Retry and Retry interval properties in General tab. For example:

clipboard_image_3.pngclipboard_image_4.png

  1. Retry argument in SSISDB stored procedure. As already mentioned in Retry package executions via T-SQL  (see above), you can use the @retry_count argument. For example:

 

DECLARE @return_value INT, @exe_id BIGINT, @err_msg NVARCHAR(150)   EXEC @return_value=[SSISDB].[catalog].[create_execution] @folder_name=N'retry', @project_name=N'Retry', @package_name=N'RetryNumber.dtsx', @use32bitruntime=0, @runinscaleout=1, @useanyworker=1, @execution_id=@exe_id OUTPUT   EXEC [SSISDB].[catalog].[set_execution_parameter_value] @exe_id, @object_type=50, @parameter_name=N'SYNCHRONIZED', @parameter_value=1   EXEC [SSISDB].[catalog].[start_execution] @execution_id=@exe_id, @retry_count=0   IF(SELECT [status] FROM [SSISDB].[catalog].[executions] WHERE execution_id=@exe_id)<>7 BEGIN SET @err_msg=N'Your package execution did not succeed for execution ID: ' + CAST(@exe_id AS NVARCHAR(20)) RAISERROR(@err_msg,15,1) END

 

These two retry methods differ as follows:

  1. Using the activity retry will generate multiple activity runs, while using the retry argument will only generate one activity run.
  2. You can set a retry interval when using the activity retry, but not when using the retry argument.

Retry preparations for editable packages

In some cases, a failed package execution can’t be retried immediately, so you need to do some preparations before retrying it. If your package is editable, you can open it in SSDT and add preparation tasks you need at the beginning of its Control Flow. For example:

clipboard_image_5.png

You can use a Script Task (Do preparation in the above package example) to clean dirty data, create/delete tables, or do anything else upstream to prepare for the following downstream tasks, ensuring that your package is retriable. Afterwards, you can follow the above Retry package executions via T-SQL, Retry Execute SSIS Package activity, or Retry package executions via Stored procedure activity sections to retry your package execution automatically.

 

Retry preparations for non-editable packages via T-SQL

If you’re using T-SQL to run your package and it isn’t editable, you can use a loop in T-SQL to prepare and retry its execution. For example:

 

Declare @max_retry_count int = 3
Declare @retry_interval nvarchar(10) = N'00:00:30'
 
Declare @exec_count int = 0
WHILE @exec_count <= @max_retry_count
BEGIN
       -- Do anything here to prepare execution
       -- Example: clean tmp table
       -- truncate table [example].[tmp]
 
       -- Create executoin
       Declare @execution_id bigint
       EXEC [SSISDB].[catalog].[create_execution] @package_name=N'<package name>',
              @execution_id=@execution_id OUTPUT,
              @folder_name=N'<folder name>',
              @project_name=N'<project name>',
            @use32bitruntime=False,
              @reference_id=Null
 
       SELECT @execution_id
       -- Wait until package execution is done
       EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id,
              @object_type=50,
              @parameter_name=N'SYNCHRONIZED',
              @parameter_value= 1
 
       -- Start execution
       EXEC [SSISDB].[catalog].[start_execution]
              @execution_id
 
       -- Check execution result
       Declare @exec_status int
       SELECT @exec_status = status from [catalog].[executions] where execution_id = @execution_id
 
       -- Check execution status to determine end execution or retry
       IF @exec_status = 4
       BEGIN
              SET @exec_count = @exec_count + 1
              IF @exec_count <= @max_retry_count
              BEGIN
                     WAITFOR DELAY @retry_interval
              END
       END
       ELSE
       BEGIN
              SET @exec_count = @max_retry_count + 1
       END
END

 

At the beginning of the loop, you can do anything to prepare for your package execution. After your preparations, you can use SYNCHRONIZED parameter to ensure that SSISDB stored procedure waits until your package execution is completed, so you can get its resulting status to determine whether to retry it or not. If its status is failed (= 4), you can wait for your specified interval and then retry it.

 

Retry preparations for non-editable packages in ADF

If you’re using Execute SSIS Package activity in ADF pipeline to run your package and it isn’t editable, you can use another ADF activity to prepare for its execution in the same pipeline. For example:

clipboard_image_7.png

You can use Stored Procedure activity (Do preparation in the above pipeline example) to clean dirty data left over by the previously failed package execution. Next, you can implement your retry logic programmatically using the framework of your choice, such as .NET, to run your pipeline, monitor its result, and rerun it if Execute SSIS Package activity fails. For example:

 

int maxRetryCount = 3;
TimeSpan retryIntervalInSecond = TimeSpan.FromSeconds(30);
TimeSpan checkStatusIntervalInSecond = TimeSpan.FromSeconds(5);
 
int execCount = 0;
while (execCount <= maxRetryCount)
{
   // Create a pipeline run
   Console.WriteLine("Creating pipeline run...");
   CreateRunResponse runResponse = client.Pipelines.CreateRunWithHttpMessagesAsync(
       resourceGroup, dataFactoryName, pipelineName
   ).Result.Body;
   Console.WriteLine("Pipeline run ID: " + runResponse.RunId);
 
   // Monitor and wait for pipeline finish
   Console.WriteLine("Checking pipeline run status...");
   PipelineRun pipelineRun;
   while (true)
   {
       pipelineRun = client.PipelineRuns.Get(
           resourceGroup, dataFactoryName, runResponse.RunId);
       Console.WriteLine("Status: " + pipelineRun.Status);
       if (pipelineRun.Status == "InProgress")
       {
           Thread.Sleep(checkStatusIntervalInSecond);
       }
       else
       {
           break;
       }
   }
 
   // Check Execute SSIS package activity status
   Console.WriteLine("Checking Execute SSIS activity run details...");
   RunFilterParameters filterParams = new RunFilterParameters(
       DateTime.UtcNow.AddMinutes(-10), DateTime.UtcNow.AddMinutes(10));
   ActivityRunsQueryResponse queryResponse = client.ActivityRuns.QueryByPipelineRun(
       resourceGroup, dataFactoryName, runResponse.RunId, filterParams);
   var ssisActivityRun = queryResponse.Value.Where((run) => run.ActivityName == "Execute SSIS package1").First();
 
   // According to Execute SSIS package activity status, decides to do retry or not
   if (ssisActivityRun.Status == "Failed")
   {
       Console.WriteLine("Execute SSIS package is Failed.");
       execCount++;
       if (execCount <= maxRetryCount)
       {
           Console.WriteLine("Sleep and retry");
           Thread.Sleep(retryIntervalInSecond);
       }
   }
   else
   {
       Console.WriteLine("Execute SSIS package is Succeeded. No need to retry.");
       break;
   }
}

 

sdkretry.PNG

 

Retry package executions partially

If only a specific part of your package is impacted by transient issues and you prefer to run other parts only once to minimize the overall running costs, then you can redesign your package to only retry the execution of that specific part. For example:

clipboard_image_8.png

clipboard_image_9.png

Let’s imagine a Data Flow task in your package that copies on-premises data to a cloud staging area (Staging Data Flow in the above package example), it’s the only part that sometimes fails due to connectivity/network issues and this always leads to a failure of the whole package execution. To avoid the complete failure, you can add a For Loop container in your package that makes Staging Data Flow task retriable.

clipboard_image_10.png

To implement your retry logic, you can first add 3 user variables and assign values to them (StagingRetryCount/StagingRetryIntervalInSecond/StagingRetryMaxCount = 0/3/5, respectively, in the above example).

clipboard_image_11.png

After adding a For Loop container in your Control Flow, you can open its Properties table and set the value of its MaximumErrorCount property to StagingRetryMaxCount + 1 (= 6 in the above example), ensuring that Staging Data Flow task will be retried at most StagingRetryMaxCount times.

Double-clicking on the For Loop container, you can open its editor and add an expression for each of its loop iteration properties.

clipboard_image_12.png

You can set the values for InitExpression/EvalExpression/AssignExpression properties as @StagingRetryCount = 0/@StagingRetryCount <= @StagingRetryMaxCount/@StagingRetryCount = @StagingRetryCount + 1, respectively, ensuring that the first loop iteration is the initial package execution, the second iteration will be the first retry, subsequent iterations will increment the retry count, and the iteration that increments the retry count beyond its maximum will be the last retry, so the loop will be exited after that.

clipboard_image_13.png

Next, you can link the Success/Failure paths of Staging Data Flow task to Expression/Script Tasks (Exit Loop/Sleep Interval in the above For Loop container example), respectively, and move all tasks into the container.

clipboard_image_14.png

In Exit Loop task, you can add an expression that sets StagingRetryCount to StagingRetryMaxCount, so the loop will be exited immediately.

clipboard_image_15.pngclipboard_image_16.png

In Sleep Interval task, you can implement a retry interval programmatically using C# based on StagingRetryIntervalInSecond variable to avoid network/service throttling.

clipboard_image_17.png

clipboard_image_18.png

At last, you can now link the For Loop container with upstream/downstream tasks from your original package (Do something/Do something else in the above package example, respectively), such that when you run the new package, if Staging Data Flow task fails, it will be retried automatically a maximum of StagingRetryMaxCount times with an interval of StagingRetryIntervalInSecond seconds between each retry.