Exception on Snowflake Internal Error Not Being Retried

Hi Everyone,

I have an Invoke Code activity inside a Retry Scope (using the default number of retries and interval) but when below error was encountered, it was never retried. Has anyone encountered this issue before?

We have increased the query timeout but the issue is still being encountered but not all the time since the process is scheduled every 15 minutes. On its next run, the process would execute it successfully .

Exception
SnowflakeDbException Error Message: Error: Snowflake Internal Error: Unable to connect. One or more errors occurred. (A task was canceled.) SqlState: 08006, VendorCode: 270001, QueryId: , Source: Snowflake.Data

Activity Setup

Logs

Appreciate your feedback / inputs on this one. Thank you!

Best regards,
Jay

Hi @iamjaredm

Are you saying that the exception thrown by Invoke code is not being caught by the Retry scope and hence it is not able to Retry?

You could do the following:

  1. Enclose the Invoke code in a Try Block.
  2. In the Catch block use Rethrow (Use a Log message before Rethrow if you need).

Thanks for the suggestions, @V_Roboto_V.

Right, the exception thrown from the Invoke Code was never caught and retried by the Retry Scope. Would you know the possible reasons for that?

Did you check in Debug (Step into) whether the Invoke Code is actually throwing any error? If the code itself executes without any error, then Invoke Code would not throw anything.

We are unable to replicate the exact exception. Rather, we used an incorrect credential in the connection string, and in debug mode it didn’t retry and just exited the retry scope. Is there something about ‘fatal’ errors that Retry Scope is not retrying those by default?

Hi @iamjaredm

I’m not sure of it, but i tried using a Try Catch inside the Invoke code, and threw an exception intentionally, it was able to Retry.


Could you try the same and check? Implement a try-catch inside the Invoke code, and throw an exception using the catch.

We’re already using Try-Catch inside the Invoke Code. For now, we’ll check this further and implement your suggestion accordingly.

1 Like

@iamjaredm
Here is what Chat Gpt says:

Default Behavior:

  • The exceptions that will trigger a retry are typically non-fatal ones. For example:
    • ElementNotFoundException: If an element is not found, the Retry Scope will retry based on the number of retries and delay you set.
    • TimeoutException: In case a timeout happens, the Retry Scope will retry the operation.

Exceptions Not Retried:

  • Fatal Exceptions (e.g., System.OutOfMemoryException, StackOverflowException, or other critical system failures).
  • Uncaught, non-handled errors (in some cases, an unhandled exception will terminate the process, preventing a retry).

Can @Anil_G @ashokkarale @Yoichi check if it’s true?

@iamjaredm @V_Roboto_V

Ideally any exception would be caught

Can you show what you are doing inside invoke code…if you are using try catch inside invoke and in catch block if you are not throwing or rethrowing the error then it would not be possible to get caught as the catch inside invoke code already handled it

Cheers

1 Like

See if your invoke code is throwing error or not
In some cases - code will be executed successfully without assigning value to output arguments due to code design. Example - Try catch within the code / value assigned to null etc

In these cases - see the output value and if it is not expected - throw exception outside the invoke code.