rails_event_store
rails_event_store copied to clipboard
Add order by when cleaning up outbox with limit
Recently we added support for cleaning up outbox table in batches, using LIMIT sql option. It is to avoid long operations on big outbox table.
We use myslq in one of outbox deployments. You can find warnings in the internet like this:
Any UPDATE, DELETE, etc with LIMIT that is replicated to Replicas (via Statement Based Replication) may cause inconsistencies between the Master and Replicas. This is because the actual order of the records discovered for updating/deleting may be different on the Replica, thereby leading to a different subset being modified. To be safe, add ORDER BY to such statements. Moreover, be sure the ORDER BY is deterministic -- that is, the fields/expressions in the ORDER BY are unique. http://mysql.rjweb.org/doc.php/deletebig
Let's add ORDER BY id to be on safe side here.
@porbas Done as I see it?