One Star

[resolved] error not caught by tlogcatcher

hello,
i have a job that looks similar like this:
tFileInputXML >> tFlowToIterate >> tPostgresqlRow
in postgres component, it's supposed to insert data to tables in the xml file. the problem now is when there's an error in tPostgresqlRow (say, table doesn't exist) it wont get logged in tLogCatcher unless i set 'Die on error' to true. this will cause the job to stop altogether. also, in tStatCatcher, the message for tPostgresqlRow for that failed insert is logged as success even though clearly in the console i can see there's failure (eg. table doesn't exist)
is there any way that i could have the error logged without halting the job completely? and have the correct error message in the tStatCatcher?
thanks
nuhaa
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] error not caught by tlogcatcher

my colleague got this working. using tRunJob seems to work!
split the job to parent job and child job. in the parent job, for tRunJob, unselect "Die on child error". in the child job, for tPostgresqlRow_1, select "Die on error".
i have 2 items in the loop. first contains syntax error, the next one is ok.
as you can see in the log, the first iteration fails and it will still proceed to process the next item, which now is a success. the whole job is considered as a success at the end, which is fine coz the status for each item in iteration is more important to me.
i hope this helps someone
nuhaa
6 REPLIES
One Star

Re: [resolved] error not caught by tlogcatcher

You can use tAssertCatcher to handle Die events. You job will not stop, but your xml -> postgreSQL subjob will stop. After the tAssertCatcher you can do whatever you like. For example, you may be able to make your xml->postgreSQL process fix itself and continue, or log the error if the error message is available. In my studio the error message is available via:
((String)globalMap.get("tPostgresqlRow_ERROR_MESSAGE"))
as you can see in the outline view.
One Star

Re: [resolved] error not caught by tlogcatcher

hey thanks alot for that guide!
i've been trying to do it like what you have described but i keep getting this error:
"If this component has output, there must be an input link to propagate the data."
my job looks like this now:
tFileInputXML >--main--> tFlowToIterate >--iterate--> tPostgresqlRow >--oncomponenterror--> tAssert >--main--> tLogRow
if i change it to
tFileInputXML >--main--> tFlowToIterate >--iterate--> tPostgresqlRow >--main--> tAssert >--main--> tLogRow
there's nothing on the console.
the expression i use for tAssert is:
((String)globalMap.get("tPostgresqlRow_2_ERROR_MESSAGE"))==''
it's noted that the variable is available 'After', i think that's the reason why nothing comes out on console. but then what should i use for assertion?
the only example i've found on tAssert is on file comparison so i'm kind of lost here.
thanks in advance for any help

Re: [resolved] error not caught by tlogcatcher

Hi,
Use tAssert only to notify the tAssertCatcher component about the error.
Let the tAssertCatcher component catch the error details.
I have attached the image of how you can use tAssert and tAssertCatcher in your case to get the desired result.
The pseudo code will look as below:
tFileInputXML >--main--> tFlowToIterate >--iterate--> tPostgresqlRow >--oncomponenterror--> tAssert --> oncomponentok --> Subsequent Codes
tAssertCatcher --> tLogCatcher / any other component
One Star

Re: [resolved] error not caught by tlogcatcher

While tAssertCatcher is a component that may help you, your tStatCatcher original design should log correctly. I did a little test and am able to record a failure in tStatCatcher when tPostgreSQLrow dies. What version of Talend are you on? I am 5.1.2.
Job looks like:
tPostgresqlRow - with "die on error" selected and "junk" as the sql string.
tStatsCatcher -> tLogRow
I get logged:
2013-02-08 06:22:00|m57O3R|m57O3R|m57O3R|79768|SHARED|test_postgreSQL_greenplum_tRow_error_logging|_ynytIHH5EeKWibyrWOq48w|0.1|Default||end|failure|483
as you can see, failure is detected.
If I add
tLogCatcher -> tLogRow then I can see the error message:
2013-02-08 06:45:04|Nu6mP0|Nu6mP0|Nu6mP0|SHARED|test_postgreSQL_greenplum_tRow_error_logging|Default|6|Java Exception|tPostgresqlRow_1|org.postgresql.util.PSQLException:ERROR: syntax error at or near "junk"|1
I tried to attach an image of the job.
DO NOT try to link the tLogCatcher and tStatsCatcher to the tPostgresqlRow component.
One Star

Re: [resolved] error not caught by tlogcatcher

hello
the ones you mentioned are working (error is logged). but in all of them i have to select "Die on error" to get the error logged in tStatCatcher. and having that selected, the job will die in the middle of iteration.
i'd like for it to recognize the error, log it and move on with the next one. i'm still looking for a way to do this.
any help is much appreciated
thanks
nuhaa
One Star

Re: [resolved] error not caught by tlogcatcher

my colleague got this working. using tRunJob seems to work!
split the job to parent job and child job. in the parent job, for tRunJob, unselect "Die on child error". in the child job, for tPostgresqlRow_1, select "Die on error".
i have 2 items in the loop. first contains syntax error, the next one is ok.
as you can see in the log, the first iteration fails and it will still proceed to process the next item, which now is a success. the whole job is considered as a success at the end, which is fine coz the status for each item in iteration is more important to me.
i hope this helps someone
nuhaa