siddhi-io / siddhi

Stream Processing and Complex Event Processing Engine
http://siddhi.io
Apache License 2.0
1.53k stars 528 forks source link

Triggering is not working as it should be #1517

Closed Jaiya94 closed 5 years ago

Jaiya94 commented 5 years ago

Description: Suppose there is a trigger that trigs every 10 seconds and from that, I am querying DBs(Using SQL queries) and there are 3 queries in siddhi app. Assume that there is a fault in SQL query of the second query out of three and it can not query the DB. And the other two queries are fine. Then when the trigger gets executed it successfully execute the first one and in the second one, it is not showing an exception and also its stop triggering. It is not executing the third one or it is not triggering next time.

Steps to reproduce:

  1. Create a siddhi app with at 3 queries and a trigger in it(By using 3 it can be easily identified).
  2. Keep 2nd query's SQL part wrong. (Syntax error or wrong table name etc.)
  3. Deploy siddhi app.

You will see only once the first query will get executed.

Format: define trigger TriggerStream at every 10 sec;

from TriggerStream#rdbms:query(Correct SQL)...... from TriggerStream#rdbms:query(Wrong SQL).... from TriggerStream#rdbms:query(Correct SQL)....

niveathika commented 5 years ago

@Jaiya94, there were two issues,

  1. Triggers not triggering properly - The error handling for triggers was not added properly, that's why you didn't see any logs or triggers stopped, which is fixed in https://github.com/siddhi-io/siddhi/pull/1515
  2. The third query not executing is the expected behaviour, since only one event is passed to all 3 streams, however, if you want to ensure the third query continues even if the second query fails, you can add three streams from TriggerStream as follows,
    
    define trigger TriggerStream at every 10 sec;

define stream Stream1(...); define stream Stream2(...); define stream Stream3(...);

from TriggerStream insert into Stream1;

from TriggerStream insert into Stream2;

from TriggerStream insert into Stream3;

from Stream1#rdbms:query(Correct SQL)...... from Stream2#rdbms:query(Wrong SQL).... from Stream3#rdbms:query(Correct SQL)....