[JAVA-2963] UnsupportedOperationException with retryable writes Created: 07/Sep/18 Updated: 28/Oct/23 Resolved: 18/Sep/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Write Operations |
| Affects Version/s: | 3.6.0 |
| Fix Version/s: | 3.8.2 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Lukáš Křečan | Assignee: | Jeffrey Yemin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I am getting UnsupportedOperationException when using retryable writes with col.findOneAndUpdate(find, update, new FindOneAndUpdateOptions().returnDocument(AFTER)).
|
| Comments |
| Comment by Githook User [ 18/Sep/18 ] | |||||||||||||
|
Author: {'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}Message: Disable retryable writes when no session is available for any reason. The only known reason that this covers is when the driver is configured
| |||||||||||||
| Comment by Githook User [ 18/Sep/18 ] | |||||||||||||
|
Author: {'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}Message: Disable retryable writes when no session is available for any reason. The only known reason that this covers is when the driver is configured
| |||||||||||||
| Comment by Jeffrey Yemin [ 17/Sep/18 ] | |||||||||||||
|
The current retryable writes and sessions specifications require that writes are not retried when there is no active session, implicit or otherwise. To comply with the specifications, the driver should (silently) not retry writes in this situation. So that's the change we'll make in scope of this issue. We'll also consider a specification change to require drivers to report an error on MongoClient construction in this case, but we'll handle that driver change in a separate issue if and when the specification change is approved. Thanks again for the report. | |||||||||||||
| Comment by Jeffrey Yemin [ 17/Sep/18 ] | |||||||||||||
|
I agree. I offered the workaround to unblock you, but I still consider this a bug and we will address it in a future release. | |||||||||||||
| Comment by Lukáš Křečan [ 17/Sep/18 ] | |||||||||||||
|
Just a last parting thought. Given that it's an unsupported combination and it's currently broken anyway, I think you can throw an exception directly from the constructor. It would prevent some unpleasant surprises for people with legacy configuration like us. | |||||||||||||
| Comment by Lukáš Křečan [ 17/Sep/18 ] | |||||||||||||
|
After removing multiple credentials, I stopped getting the exception. | |||||||||||||
| Comment by Lukáš Křečan [ 17/Sep/18 ] | |||||||||||||
|
Thanks a lot, I will try it today and confirm if it indeed was the case. As a user I would prefer at least a warning, when an unsupported combination is encountered. Thanks again. | |||||||||||||
| Comment by Jeffrey Yemin [ 16/Sep/18 ] | |||||||||||||
|
I suspect that the issue is with the multiple databases list. MongoDB sessions, on which retryable writes depend, do not support connections on which more than one user is authenticated. The driver should detect this and disable (silently) retryable writes, but it appears that it's not doing so. Since retryable writes are not supported with multiple credentials, the workaround for this bug is to either
| |||||||||||||
| Comment by Lukáš Křečan [ 16/Sep/18 ] | |||||||||||||
|
There are 3 elements in serverAddresses list and 3 elements in databases. | |||||||||||||
| Comment by Jeffrey Yemin [ 14/Sep/18 ] | |||||||||||||
| |||||||||||||
| Comment by Jeffrey Yemin [ 07/Sep/18 ] | |||||||||||||
|
For reference: https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst#requirements-for-retryable-writes | |||||||||||||
| Comment by Jeffrey Yemin [ 07/Sep/18 ] | |||||||||||||
|
Not explicitly. The driver will create an implicit session assuming that the server version is >= 3.6 and the cluster is either a replica set or sharded and not a standalone. | |||||||||||||
| Comment by Lukáš Křečan [ 07/Sep/18 ] | |||||||||||||
|
Actually, the code looks like it requires clientSession for retryable writes to work, but I can not find any mention of it in the documentation. | |||||||||||||
| Comment by Lukáš Křečan [ 07/Sep/18 ] | |||||||||||||
|
Constructor:
Server version: 3.6.6 | |||||||||||||
| Comment by Jeffrey Yemin [ 07/Sep/18 ] | |||||||||||||
|
So we can diagnose this faster, please provide
|