Re-execute on error

Hello.

I have an issue with a workflow whereby a node may error and needs to be manually re-executed. I believe the error may be caused as I run concurrent nodes with RFC connectors which can’t always connect first time. Whilst one option would be to run each node separately, this would not be the ideal as it would take too long.

Is there a simple method by which I could restart a node which has stopped? This is possible with the Try/Catch nodes but seems overly complicated and I’ve been unable to work out how to implement an infinite Try/Catch loop.

Currently I have a simple program, external to Knime, which presses F7 every 10 seconds to restart the workflow if it has stopped, but this isn’t the most practical solution as it cannot run in the background.

Any help would be greatly appreciated!

Kind regards

David

Hi David,

I think I have found a method to do what you need:

In this example workflow I have a Get Request node which may produce an error while executing (for example when there is no connection if you check the option in the configuration window).

I could loop over the nodes until they executed successfully and I got what I wanted (in this case a list of countries).

I used a “Generic Loop Start” and “Try” before the main nodes (no configuration) and after the main nodes used “Catch Errors”. Now for the input port which will be used in case of error, I used a table creator which contains exactly the same structure as the other input port of the Catch Errors node but with 1 row and some value like “error” for a column (which will be used as a condition to continue or stop the loop).

Then I used a Table Row to Variable node to convert the first row of any output to variable and fed it to the “Variable Condition Loop End”. In the configuration window of the “Variable Condition Loop End” node, I selected the variable which is derived from the column for which I have entered the “error” value in my table creator just before the Catch Errors node. And for the condition to end the loop I chose “not equal” sign (!=) and set the value to “error” which means the loop will stop whenever the value of this variable is not “error”. And I checked the option to “collect row from last iteration only” so I will only have the output from the main flow.
loop%20end

Please check the workflow and let me know if it’s what you need:
re_execute.knwf (89.7 KB)

Best,
Armin

10 Likes

Hi Armin,

That works perfectly!

Many thanks for your help and the quick response.

Kind regards

David

1 Like
7 Likes

This post is the closest one I’ve found to my issue, but I’m hoping someone can help. I have a Microsoft SQL Server Connector node that gives me the following error after not being used for a while, such as the next day when I come to start working on it again.

ERROR Microsoft SQL Server Connector 0:3003 Execute failed: Database ‘XXX-knime’ on server ‘XXXXX.database.windows.net’ is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of xxxxxxxx

If I reset the node 2 or 3 times, it magically connects and moves on, as if the SQL database was asleep or something. I can’t figure out how to automate a way to keep trying the node until its connection is accepted. Any ideas?

If you use new DB framework then on your Connector node Advanced tab check the last parameter - Restore database connection. Take in account that re-establishing of connection may take some time depending on specific DB.

2 Likes

Thanks for the quick reply. I checked this box while trying to test things earlier, but it didn’t seem to do anything. What would I expect? Would I expect it to just show ‘executing’ forever until it finally connected?

have you tried wrapping it in a try - catch loop?

Maybe? I tried incorporating them, but since this doesn’t produce a data or variable port, I couldn’t understand how to do get the “try” part incorporated.

I also tried the example above here, but since the SQL Server Connector has no ‘incoming’ data port, I tried to force it to reset every time the loop would run, but that didn’t work. It errors and never produces a dataport, so it just fails and won’t move forward for me. Here’s where it sits right now using the example in this thread.

I see - this is not too dissimilair to re-try on fail issue i recently resolved.

Wrap the connector only between the try and catch.
Rather than connect the flow variable out to the connector use a table to variable.
here is a screenshot of the setup: I uploaded the component to hub just now, so should be available shortly if you want to reverse engineer.

This looks promising, thanks! How can I find the re-try component? Where is the hub?

Ah sorry, the component is called Google Analytics Query - 120Feet Edition. It’s still not visible in the hub.

It’s not a re-try component per se…
i just used the try and catch nodes together with a recursive loop as per the screenshot

Ahh, gotcha. Thanks! I’ll give it a shot in a bit and report back

Alright! This seemed to work. I don’t know if it’s the cleanest way, but I’ll record what I did for reference. My object is to ‘wake’ a sleeping SQL database connection automatically. My challenges in using try-catch were that it’s not a data node, but I need to somehow have it keep retrying. I used the suggestions and came up with this method.

  • Objective is to leave this part of the workflow with data that will be written to a SQL table that’s defined after the Concatenate node in the picture. If that’s successful, that means my SQL connection was successful
  • I bring my model parameters table creator into the generic loop start with a variable condition loop end
  • I ‘know’ that it usually takes no more than 3 repetitions for me to reset and rerun the SQL connection manually to get it to finally work. So I set the variable condition to >= 5 iterations (based on current iteration)
  • I used the try (data ports) node right after the generic loop start and put the catch errors (data ports) right before the variable condition loop end
  • Within these loops, I connected the table row to variable to the SQL server connector DB, but I needed ‘data’ to use in the catch errors area, so I continues with the table selector and DB reader nodes so that I would have ‘data’ upon success of the SQL server connector for the top port of the catch errors node.
  • Upon success, the DB reader data passes through the loop end, which has an iteration column 0, 1, 2, 3, and 4. I don’t really want this data to be moved forward as I’m just using it to have ‘success’ data. So I clear out all rows and columns and, instead bring in my original model parameters data that I DO want to write to the SQL db

This appears to work, but I’ll edit this post if I find out otherwise later.

Thanks for all the help!

2 Likes

Just to share for retrying GET Request Error with simple way.
This workflow is available in KNIME hub. link

3 Likes