Inconsistent sorting of upsert operations (v3.13.3) #1766
Unanswered
MathiasOlsenNuuday
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there.
I'll start this discussion as a question, as I am experiencing inconsistent behaviour on our deployed application pods that uses marten, which I am unable to reproduce locally. Before I start an actual GitHub issue, I would like to hear if my assumption about operation execution sorting is correct.
Recently we have been running into a minor amount of dead locks, when attempting to upsert two distinct documents as a part of the same transaction, which doesn't have any relationsships to eachother or any other documents.
The root cause seems to be a ShareLock:
This lead to me investigating the order of execution of the marten operations when translated into sql queries. But I don't immediately see anything in the following code (and the underlying method calls) that would force different sorting of the operation execution. Consider that we don't have any foreign key relationsships in the mentioned documents.
UnitOfWork.cs
However when looking at our production logs, I was able to see that in some cases, the order of execution was reversed for the two documents: (Which is likely also what's causing the deadlock)
Example 1:
Example 2:
(The above is derived from the correlating NpgsqlCommand CommandText.)
Question: Am I right to believe that there shouldn't be anything in the sort implementation, that would result in these upserts being sorted differently?
Beta Was this translation helpful? Give feedback.
All reactions