-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.12.0
-
Component/s: Connection Management
-
None
A DBPort maintains a usageCount which is incremented upon each usage of a DBPort. In the case of an UNACKNOWLEDGED write, this usageCount is utilized by WriteResult to indicate when a subsequent call to getLastError() is unsafe because its DBPort has already been checked out and used by another thread. (To be fair, a deprecated pattern as of 2.13.0.)
The race is that while non-write command operations using DBPort.say() and DBPort.call() do ensure the usageCount is safely incremented, write commands go through DBTCPConnector and do not increment this counter.
Therefore it's possible that a write command on one thread may end up sharing a DBPort for a getLastError() call on another thread, resulting in undefined behavior.
Available Workaround
Use ACKNOWLEDGED writes whenever a getLastError() result is required, such as for a WriteResult.getUpsertedId().
Credit: jeff.yemin for analysis and discovery.
- is duplicated by
-
JAVA-1632 IllegalArgumentException: response too long: 1701078386
- Closed