[JAVA-3608] updateOne blocked due to ?retryWriter=true and WriteConcern.UNACKNOWLEDGED combination Created: 27/Jan/20 Updated: 25/Feb/20 Resolved: 25/Feb/20 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Write Operations |
| Affects Version/s: | 3.12.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Hendy Irawan | Assignee: | John Stewart (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java 8, MongoDB Atlas M5 4.2.2 |
||
| Issue Links: |
|
||||||||
| Description |
|
There is a very specific combination of factors that must be fulfilled for this to happen:
e.g. userColl.withWriteConcern(WriteConcern.UNACKNOWLEDGED).updateMany(in("_id", ids), inc("impressionCount", 1)); db.user.updateMany({_id: [466]}, {$inc: {impressionCount: 1, {w: 0});}}
db.user.updateOne( {_id: 466}, { $set: { 'email': 'hendy@hendyirawan.com
Note that this bug is not reproducible when using mongo shell, so I think this bug is specific to MongoDB Java Driver. At first I thought it is due to codecs or thread safety or server busy, but even just updating a string reproduces the issue. Workaround: Don't use WriteConcern.UNACKNOWLEDGED (with ?retryWrites=true). As long as I update always with w=1 or w=majority, there is no issue. |
| Comments |
| Comment by John Stewart (Inactive) [ 25/Feb/20 ] | ||||||||||||
|
hendy@hendyirawan.com The cloud team was able to identify the cause of the issue and they have opened the ticket CLOUDP-58004 to work on this. You can follow that ticket for further updates. If that ticket fails to resolve this issue, I will reopen this bug. | ||||||||||||
| Comment by Hendy Irawan [ 11/Feb/20 ] | ||||||||||||
|
Thank you John ! | ||||||||||||
| Comment by John Stewart (Inactive) [ 11/Feb/20 ] | ||||||||||||
|
hendy@hendyirawan.com I was able to reproduce the hang in the mongo shell with an M5 instance. After executing the update with w=0, I get the response acknowledged: false and then a hang:
I am then unable to execute any other commands. Entering Ctrl-C generates an exception and dumps a backtrace. I am using the mongo shell version 4.2.2. | ||||||||||||
| Comment by Hendy Irawan [ 10/Feb/20 ] | ||||||||||||
|
Thank you very much @John ! And that is good news... I hope you'll find the root cause soon | ||||||||||||
| Comment by John Stewart (Inactive) [ 10/Feb/20 ] | ||||||||||||
|
I am able to replicate this issue only with an M5 instance. I am investigating further. | ||||||||||||
| Comment by Hendy Irawan [ 04/Feb/20 ] | ||||||||||||
|
Did you get the driver complaining "Driver will log that retryWrites=true cannot be used with unacknowledged."?
So far the difference is:
| ||||||||||||
| Comment by John Stewart (Inactive) [ 03/Feb/20 ] | ||||||||||||
|
hendy@hendyirawan.com I created a test based on your description and ran it successfully against a 4.2.2 replica set. Since retryWrites=true is the default, I ran the test with and without ?retryWrites=true in the connection string, but I could not reproduce your issue. Here is my test:
Could you point out the differences between my test and your scenario? Thanks. |