[JAVA-2651] Unable to exit from hasNext() for tailable cursor if cursor was closed from another thread Created: 03/Nov/17 Updated: 29/Oct/23 Resolved: 10/Nov/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Query Operations |
| Affects Version/s: | 3.5.0 |
| Fix Version/s: | 3.6.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Igor | Assignee: | Jeffrey Yemin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
WIndows 10, Java 1.8 |
||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Description |
|
Unable to exit from hasNext() for tailable cursor if cursor was closed from another thread
before getMore(). So if cursor was closed from another thread, hasNext() will exit. But this should be done in thread-safe way. |
| Comments |
| Comment by Githook User [ 10/Nov/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 06/Nov/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Further investigation shows that I still think, as suggested, that the driver could check itself for a cursor that's been closed, so I'll leave this issue open as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor [ 06/Nov/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here is the example where I can reproduce it:
When exiting (Ctrl+C) you will se next
When waiting for exit, if you will insert new document(e.g. from Robo 3T), you will get
which signals that hasNext() has reacted on cursor.close() only after new document was inserted during shutdown. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 06/Nov/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
My tests show that hasNext() will eventually exit if the cursor is closed, as the getMore will fail. The exception, though, is not what I expected:
Can you verify that you're seeing different behavior? Here's my test program for reference:
One caveat: if I add less than two documents after starting the tailable cursor but before closing it, I do get the hanging behavior that you observe, so perhaps that's what's happening. This appears to be a server bug. |