punnP
Convex Community3y ago
7 replies
punn

Mutations race condition

I have a table called messageBuffer that does the following:
- Creates a new row for some conversation's first message
- If another message in the conversation arrives, we append a buffer variable within that conversation's row
- After 30 seconds, each message in buffer is processed, and the row is deleted (note: this deletion happens in an action that takes a long time to execute).

I'm currently running into the issue of losing message_2 in the following scenario:

for one conversation,
message_1 arrives
30 seconds pass and we begin to process and flush the buffer
message_2 arrives
buffer is deleted
message_3 arrives
.....

Am I able to fix this by replacing my deletion with an updateOrDelete function instead?
Was this page helpful?