bacalhau-project / bacalhau

Compute over Data framework for public, transparent, and optionally verifiable computation
https://docs.bacalhau.org
Apache License 2.0
643 stars 85 forks source link

Atomic enqueue of evaluations #3972

Closed wdbaruni closed 1 month ago

wdbaruni commented 2 months ago

In many places we update the state of jobs or executions, then create an evaluation, and then enqueue the evaluation to the broker. All of these operations are not atomic and not in a single transaction. This can result in a lot of edge cases and potentially dangling or stale jobs and executions due to partial update of their state, but failure to trigger their re-evaluation.

We need to look into ways to do these operations atomically in a single transaction. This is might be easier to update the job state and create an evaluation in a single transaction as they are part of the same datastore, but the evaluation broker has its own in-memory state, and we need to figure out a way to implement state watchers where we don't need to explicitly enqueue evaluations, but allow the broker to consume state events and enqueue an evaluation whenever one is created