[JAVA-1613] Race condition on DBPort usage during write commands Created: 07/Jan/15 Updated: 01/Apr/16 Resolved: 07/Jan/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Connection Management |
| Affects Version/s: | 2.12.0 |
| Fix Version/s: | 2.12.5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | John Morales | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
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 Credit: jeff.yemin for analysis and discovery. |
| Comments |
| Comment by Githook User [ 07/Jan/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: Fixed race condition between threads attempting to get the result of an unacknowledged write after the fact and threads attempting to do write commands. |
| Comment by Githook User [ 07/Jan/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: Fixed race condition between threads attempting to get the result of an unacknowledged write after the fact and threads attempting to do write commands. |