Problems when creating a new Saga

Hi,

We’re currently having a mysterious issue with one of our Sagas. During some rare occasions (don’t know more about the details here) a Saga that is just started get’s immediately deleted again. It’s a synchronous saga event handler that is executed by a SimpleMessageListenerContainer, persisted to a JPA repository backed by a MySQL store. From what I can see, the only reason why it would get deleted from Axon code, would be that the saga is considered ended which impossible from what I can see. The event handler that starts the saga looks like this

`

@SagaEventHandler(associationProperty = “aggId”)
@StartSaga
public void handle(ObfuscatedDomainEvent event) {
this.aggId = event.getAggId();
sagaExpirationScheduleToken = eventScheduler.schedule(Duration.standardHours(1), new ObfuscatedSagaExpiredEvent(event.getAggId()));
}

`

and there is no other events related to this saga that is being handled before it gets deleted.

The proof for the deletion is from the mysql transaction log, which shows that it’s deleted just the second after it was inserted.

Any wild guesses out there for could possibly be the reason for this behaviour?

Cheers
Sebastian

Hi Sebastian,

Axon checks if a Saga is marked for deletion, so that must have happened somehow. Doesn’t the ObfuscatedSagaExpiredEvent() trigger deletion of the saga? Could it be that the eventScheduler fired eagerly? Which implementation do you use?

Cheers,

Allard

Hi,

And sorry for the late reply. I started filtering the mails from this group making bypass the inbox but have forgot to check the label…

According to the mysql transaction log the scheduled ObfuscatedSagaExpiredEvent get’s fired at the right time, an hour later and ends the second instance of this saga that was created by another event which came in a couple of seconds later. The insert and delete of this instance of the saga gets executed, according to the transaction log, the same millisecond with nothing else happening in between.

The implementation of the scheduler is the QuartzEventScheduler if that was what you where referring to.

As you said, the only reason for the saga being deleted should be that is was flagged as ended somehow but I can’t for my life figure out how that could happen, and certainly not during the handling of this single event which seems to be the case.

Hi Sebastian,

that’s the association value you use to make sure the triggered event gets handled by the correct Saga? Might another saga accidentally also be triggered by the scheduled event?

Cheers,

Allard

Not that I can see. The saga instance and associations are inserted and then deleted, nothing else happens in between, including no activity in the quartz database, expect for the created schedule.

We’ve hopefully fixed the saga by removing this second entry point and also removed the scheduled event to whatever the issue was, it will not appear any more now that the saga is a lot simpler.