Skip to content

Conversation

mlarribe
Copy link

@mlarribe mlarribe commented Oct 15, 2025

Context:

I was testing the feature Mongo.replace_one with the enabled params : upsert: true, retryable_writes: true when I found out that none of my document was getting updated despite the change on the documents every time from an extract to next the very first attempt to replace_one.

The digging

After some investigation I found that the issue was linked to the retryable_writes behaviour that was "using/re-using" the same sessions lsid and txnNumber.
From the documentation reusing the same lsid was supposed to be ok but not for txnNumber, I was surprised to discover that the lsid and txnNumber was staying exactly the same after multiple find_one followed by some minor change on the doc followed by an attempt to be Mongo.replace_one again. (the session_server was reused without increasing the txnNumber)

Thanks

Big heads up to log feature: log: &IO.inspect/1 that helped a start diagnose it even from a novice experience on the driver it self

I did some dummy test on own, and it solved my issue.
I may still have miss edge case so, Peers review will be very appreciated, I'm still very on the learning curve of the driver

…ion to prevent silent no-write operation

fix retryable_write faulty, fix the issue that prevent replace_one to occures on concecutive update on the same document when sessions is checkin and then reused again (same document or different does matter, it's stays silently blocked until the session expires)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant