DELETE_MISSING_KEY error on aggregate.trigger() on trigger (convex helper)
im trying to create a count aggregations on an existing table.
i manage to run the migration as per below
and so far the backfill works fine. which i can see the aggregates count numbers are correct.
but when i add the code to my trigger function (to update the triggers automatically).
i got the error above.
20 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
i could be using .idempotentTrigger(), but i feel like its not the right way to handle things
can you explain in detail how you did the migration
from what you describe, it sounds like you skipped step 1 here https://www.convex.dev/components/aggregate#attach-aggregate-to-an-existing-table
hey
i cant tell if thats making any difference because on my current dev env is stale (no changes happening in realtime)
but let me try again
okay i run the backfill
with this code in place
im going to change from idempotentTrigger to just trigger
if you did step 3 of the migration before step 1, your data is probably incorrect and you'll need to reset it
still getting this after mkaing the change
yeah it sounds like your data is still out of sync
but i just ran the migration
no i didnt
if your data is out of sync, you need to reset it first, then do the migration steps in order
okay here's the reset code
i just run it
now im migrating again
@Lee on step 1-2, do i need to use idempotentTrigger() instead of trigger(). any difference ?
@Lee it works!!!
finally i can ship this
can you help confirm this
step 1 says
Use insertIfDoesNotExist/replaceOrInsert/deleteIfExists in place of insert/replace/delete (or idempotentTrigger in place of trigger) to update items in the aggregate
hey @Lee im running the migration on prod but encountering an issue
oh i need to change the batch size
my question now, if the migration fail, should i just continue or do need to reset the aggregates ?
as long as the idempotentTrigger is in place, you can just retry/continue the migration