cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting subscribers to a signal is not working in Postgres

jwestra
Champ in-the-making
Champ in-the-making
Hi!

I have a process definition with a SignalStartEvent.  When I execute signal received on it using the "in-memory DB", an event subscriber is found and fired, starting the process. 

However, when I run the application under Postgres using the same process definition, the query returns zero rows for subscribers and no process instance is ever started.  To make matters worse, when I take the SQL in the logs, run it in DBVisualizer with parameters like eventName and tenantId populated, the SQL is correctly returning an event subscriber row!

So, it appears the binding of the "parameter.eventName" and the "parameter.tenantId" are not working in Postgres.


<select id="selectSignalEventSubscriptionsByEventName" resultMap="eventSubscriptionResultMap" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject">
    select *
    from ${prefix}ACT_RU_EVENT_SUBSCR EVT
    left outer join ${prefix}ACT_RU_EXECUTION EXC on EVT.EXECUTION_ID_ = EXC.ID_
    where EVENT_TYPE_ = 'signal'
       and EVENT_NAME_ = #{parameter.eventName}
       and (
        (EVT.EXECUTION_ID_ is null)
        or
        (EVT.EXECUTION_ID_ is not null AND EXC.SUSPENSION_STATE_ = 1)
       )
    <if test="parameter.tenantId != null">
        and EVT.TENANT_ID_ = #{parameter.tenantId}
    </if> 
    <if test="parameter.tenantId == null">
        and (EVT.TENANT_ID_ = '' or EVT.TENANT_ID_ is null)
    </if>  
</select>



select * from ACT_RU_EVENT_SUBSCR EVT left outer join ACT_RU_EXECUTION EXC on EVT.EXECUTION_ID_ = EXC.ID_ where EVENT_TYPE_ = 'signal' and EVENT_NAME_ = ? and ( (EVT.EXECUTION_ID_ is null) or (EVT.EXECUTION_ID_ is not null AND EXC.SUSPENSION_STATE_ = 1) ) and EVT.TENANT_ID_ = ?



This query totally returns the proper event subscriber when run from DBVisualizer to Postgres!!  Weird?

select * from ACT_RU_EVENT_SUBSCR EVT
left outer join ACT_RU_EXECUTION EXC on EVT.EXECUTION_ID_ = EXC.ID_
where EVENT_TYPE_ = 'signal'
and EVENT_NAME_ = 'UserUpdated'
and ( (EVT.EXECUTION_ID_ is null) or (EVT.EXECUTION_ID_ is not null
AND EXC.SUSPENSION_STATE_ = 1) ) and EVT.TENANT_ID_ = 'tenant1'





4 REPLIES 4

jwestra
Champ in-the-making
Champ in-the-making
I spun up a MySQL on AWS and tested against it as well.  It runs fine.  That makes H2 and MySQL as working fine.  So, something is amiss in the way the Postgres DB is handling the PreparedStatement markers ("?") for this particular query.

jbarrez
Star Contributor
Star Contributor
That sounds _very_ odd … do you have a simple unit test that demonstrates this problem on postgres?

jwestra
Champ in-the-making
Champ in-the-making
Joram, 

My team is under a tight deadline until mid-June.  We definitely want Postgres long-term, so I will re-visit it and post a junit at that time.  We have a reasonable workaround using MySQL until then.

Jason

jbarrez
Star Contributor
Star Contributor
ok, thanks.