Event stream guaranteed order

Hello everyone,

I’m materialising Nomad job updates to an SQL database (current status of all jobs). I have a service subscribed to the job topic and it blindly writes all event payloads to the database (without checking the event index/modify index in the event payload).

I’ve tried to figure out if this method is safe or not from the Nomad codebase: from what I can tell both the event index and the modify index correspond to the current (committed) Raft log index.

Is it safe to assume that events are received in guaranteed order on the API?

Thank you in advance and best regards,
Szabolcs

Hi @szabolcsgelencser,

Yes the events are fed directly from Raft, therefore the ordering will be as you detailed. One thing to consider when blindly writing is situation where your application is interrupted or restarted. In this situation you’d likely want some form of reconciliation otherwise you would be replying the events and potentially writing duplicate data to your DB.

Thanks,
jrasell and the Nomad team

Hi @jrasell,

Thank you very much! Its actually persisting the latest event stream index to continue from that point on restart (its just not checking whether we got a previous index on writing changes to the database).

Thank you and best regards,
Szabolcs