Hi,
I have a sync nodejs job I need to run every day. I do parallel upserts for each document with the following generic function
const upsertDoc = async (doc, coll, index, terms) => {
return client.query(
q.Let(
{
m: q.Match(q.Index(index), terms),
},
q.If(
q.IsNonEmpty(q.Var("m")),
q.Replace(q.Select("ref", q.Get(q.Var("m"))), { data: doc }),
q.Create(q.Collection(coll), { data: doc })
)
)
)
}
Every upsert is applied to a different doc. I’m not manipulating the same doc.
The problem is I’ve started to get the Transaction was aborted due to detection of concurrent modification
error with a parallelism level of 4. I’m really confused because this used to work and I can’t think of anything I’ve changed that might cause this. But obviously, there is something.
I’ve tried creating the client in the upsertDoc
function too. That didn’t help, although I don’t know what’s the best practice here.
I’d appreciate any clue that might help.