-
- Downloads
Emit events outside of db/transaction (#15909)
* Emit events outside of db/transaction When emitting events (particularly revision events), the event handler loads the item from the db to ensure that all post-processing is done. If done from inside a transaction, there's a race between the event handler looking up the object from the db and the transaction completing to put the item in the db. When the event handler wins, the following code fails: ```clojure (push-revision! :entity Dashboard, :id id, :object (Dashboard id), ;; this is nil :user-id user-id, :is-creation? (= :dashboard-create topic) :message revision-message) ``` and then the schema check for `push-revision!` fails `(map? object)` and there is no event recorded for creation. On edit, it might get the pre-edit version and record an incorrect message or not create the revision for the latest change, preventing going back in the future. I'm only doing this in dashboard but these changes should be audited and applied everywhere * Remove `:dashboard-card-update` and `:dashboard-card-create` events These events were introduced 5 years ago and never have had an event handler. No worries about race conditions when emitting them from a transaction if nothing ever cared in the first place.
Please register or sign in to comment