Triggers will fail after first run due to connection lost/pooling issues.

Triggers will fail after first run due to connection lost/pooling issues.

book

Article ID: KB0082314

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization 7.0.5

Description

Symptoms:
Trigger fires off script that runs DELETE command on table in database and then INSERT. First run of the trigger will succeed. All subsequent trigger requests fail with this error: 
Message=The repository connection is closed. id=146860106 cid=30605 name=EDW_TD14 connection id=255 

This error is also present in the dsrc logs: 
ERROR 2018-01-22 08:55:30.922 -0500 datasource - Failed to activate object from pool. The object will be abandoned. Reason for activation failure: com.compositesw.common.pool.PoolableInvalidException: [The connection identity is com.teradata.jdbc.jdk6.JDK6_SQL_Connection@65198cff The create time is 22/01/2018 01:45:40.507 Last access time is22/01/2018 01:46:26.163] 

As well as this error in the task logs: 
ERROR 2018-01-22 09:23:13.851 -0500 TriggerManager - 
The repository connection is closed. id=146860106 cid=30605 name=EDW_TD14 connection id=255 

If the script (called by the trigger) is executed manually, it completes without any exceptions. Also, after the failure, if we go into the trigger and make any change (like change to the schedule), run it again, that would finish successfully as well. Although, if we let the scheduler run, that would fail for the second run.
 
Cause: There is a limitation with Teradata datasource when Delete and Insert statements are run from within the same session. 

Issue/Introduction

if any change is made to the trigger (like change to the schedule), run it again, that would finish successfully. Although, if we let the scheduler run, that would fail for the second run.

Resolution

Put Delete in a separate Procedure and call it with a separate trigger. Put Insert in a separate Procedure and call it with a separate trigger

Timed it appropriately (4 minutes apart). They are working fine now.