what does this error mean
my understanding is that mutations are transactions that also include built in conflict resolutions. I'm not sure what this means?

22 Replies
this is what my mutation is doing
I have maybe 10 other tasks that might run this same mutation at the same time

is this related to me having a .any() field where I store a giant json object?
I guess I can also ask about this one

convex ai helper says network glitches can cause this, but is this something rare?
my understanding is that mutations are transactions that also include built in conflict resolutions. I'm not sure what this means?that's right, the built-in conflict resolution works by rolling back the effects of a mutation if it steps on another mutation's toes and carefully rerunning the mutation. There's a limit on retries though: if these keep failing the system returns a failure like this.
is this related to me having a .any() field where I store a giant json object?That can increase the length of time the mutation takes and therefore that the transaction is open for so this could be related.
I have maybe 10 other tasks that might run this same mutation at the same timeAre these mutations reading and writing the same planId? If not this is really unexpected.
yeah I mean the mutation just does those 2 lines
fetches the plan
patches the plan.plan property
One way to hve less contention would be to split out keys to be records in a different table so that modifying one key doesn't interfere with modifying another key
I have 1 action which uses the scheduler to run 11 actions, each of those actions runs a query to fetch the plan info, updates the plan to "generating" status, then it uses openai to generate some data, then it writes back to the plan the generated data
yeah I may look into doing that
roughly
was prototyping as well and i got htis
We're thinking about how to help people debug these situations, this error message text changed fairly recently I think, trying to describe the read/write conflicts
oh I forgot value
cool yeah
does the composite index make sense in this situtation do you think?
yeah, it lets you get a specific type or all types for a planId
which is a common query since you need that to construct the plan

how do I re-use the same v.union I defined in the schema?

like can I just define like this at the top of the schema, then import in my action for defining my args?
Yep, you got it right!
We just put out an article or two on managing the types: https://stack.convex.dev/argument-validation-without-repetition
and
https://stack.convex.dev/types-cookbook
Argument Validation without Repetition
In the first post in this series, the Types and Validators cookbook, we shared several basic patterns & bes...
Types and Validators in TypeScript: A Convex Cookbook
It can be tough to wrangle types to behave how you want them to. Thankfully, Convex was designed to make the experience with types perfect. Learn why ...