conflict write warnings, and excessive DB reads
I have lots of write warnings, and my function, which is only inserting, is causing high DB read bandwidth usage. This is the code for the function:



3 Replies
It’s a little more complex as the mutation is wrapped to also accept an apiKey as arg (why it’s called serverApiMutation) and also have a custom trigger to call aggregate table update.
The code for the trigger looks like this:
I have attached a screenshot fo the warnings, what is strange is the job _ids reference in the warning don’t exist.
The bandwidth seems strange that the each call to insert a jobRun is reading 102 documents, should only be 1?
I haven't used triggers before, but I know the basic concept. Something tells me you've got some recursive triggering going on because writing to the
jobRun table triggers further changes in the same table. On the surface it looks like you've checked for this, but there are parts of your logic that you haven't shared here.
My only suggestion would be to review everything involved and scrutinize the logic very carefully to see if you can find anything that might lead to recursive behavior.I have reviewed code, and nothing obv on my side stood out. I only have one other trigger on the job table to handle aggregates and deleting jobRuns (to work similarly to SQL DB Cascading).
I like convex, but the aggregates and trigger solution seem half-complete. For example, I have to constantly remind myself not to edit data in the UI dashboard, else it breaks the whole DB. And triggers do feel like a footgun waiting to happen.