[Events replaying] Missing database records created by a previous @EventHandler

Hi there,

I’m using Axon 4.5.3 with Axon Server SE 4.5.6, using Spring Data to manage my read model.

I’m facing an odd issue when replaying my events with a “traditional” tracking processor (not the pooled one).

Increasing/decreasing the segments/threads don’t change anything. The batch size is the default one, 1.

I have a bunch of events whose timestamps are really close as they have been generated by a data import process. The sequencing policy is the default one as well, using the aggregate id.

Let’s talk about the events replaying now.

The first event will trigger the creation of an entry with partial data that will be updated by the handling of the next event. Later on, new entries will be created using the first one as a template.

The issue I’m facing now is that this first entry is not always found (I throw an error in that case that will put the TP in error mode as I change the default error handler logic).

I suspected this could happen with a batch size > 1 as we might one single transaction for the whole batch, but not in the current case. I’m not sure if this related to Hibernate optimization itself or Axon but I’m still looking for clues.

When I debug the @EventHandler where I expect to find the previous template entry, I can confirm this previous record is not (yet) in the database. Then I tried to disable this @EventHandler completely and replay the TP with only the @EventHandler creating the first entry enabled, and in that case, I can find the records in the database.

It really looks like the transaction is not committed when expected, or at least delayed enough to make the look up failing when the next event is processed.

Are you aware of any reason that could explain this behavior ? I’m trying to set up a datasource-proxy to be able to selectively log what I need for debugging but this is time consuming.

Thank you,

Hi @Jerome_M,

That is a bit odd indeed, so let me ask you a question.
Are those 2 EventHandlers (the one which create your entry and the one which uses it as a template) part of the same processing group (and same token)?
If that is the case, they should share the token and I wouldn’t expect it to happen → would look into hibernate/spring data to check when things are really flushed
If that is not the case, than it could happen as both processors will be running in parallel.


Hi Lucas,

Thank you for your answer (and for fixing my typo and formatting :wink: !

These 2 event handlers are indeed part of the same TP ( I expect them to use the same token as well as the sequencing policy should guarantee that), hence my confusion. I guess this is very circumstantial, I might need to reproduce it in a sample project.

I’ll post my findings here if I feel it could help someone else.