How can someone seed the database without triggering the hasura events? #8556
-
Hi, I've been stuck on this issue for a week. I've got several hasura instances, each has its own events, webhook servers, table history tracking and so on. All the servers are communicating through a pub sub system, so an event in one hasura instance may affect any of the other servers. We can't clear the metadata because then the database would be disconnected, we can't pause the triggers because Hasura doesn't have the option, we can't stop the webhook server because then Hasura will retry when the server is back up, dumping the data right into the database would also trigger the events. Has anyone found a workaround to this, because I'm sure I'm not the first one to have this issue |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
A bit of a hack, but you can add this at the bottom of your seed file: DELETE FROM hdb_catalog.event_log WHERE created_at = current_timestamp; Note you probably should constraint if further, eg by the name of the event triggers you expect to trigger. Please also test this in a dev environment before committing to using it in prod, there is a risk you could lose unprocessed events if my logic is unsound. Why this works: hasura events work by creating postgres triggers that will queue up events in To identify these events, we take advantage of |
Beta Was this translation helpful? Give feedback.
A bit of a hack, but you can add this at the bottom of your seed file:
Note you probably should constraint if further, eg by the name of the event triggers you expect to trigger. Please also test this in a dev environment before committing to using it in prod, there is a risk you could lose unprocessed events if my logic is unsound.
Why this works: hasura events work by creating postgres triggers that will queue up events in
hdb_catalog.event_log
for later processing.We can delete theses entries before they have a chance to be processed by removing them in the same transaction we queued the up.
To identify these even…