[CXX-2126] Error "cannot run getMore on cursor" is occasionally thrown Created: 06/Nov/20 Updated: 27/Oct/23 Resolved: 19/Nov/20 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | API |
| Affects Version/s: | 3.4.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Malik Mokhadri | Assignee: | Clyde Bazile III (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 |
||
| Description |
|
Occasionally, running getMore command on a cursor would throw the following error:
Example Code:
Are different connections allowed to use the same implicit session or not? In other words, can a cursor ID returned by a find command be used with a getMore command but using a different implicit session? This doesn't seem to be well documented. |
| Comments |
| Comment by Clyde Bazile III (Inactive) [ 19/Nov/20 ] |
|
Thank you for your patience. To answer your question, no, getMore commands on a cursor must use the same session ID (whether implicit or explicit) as the find or aggregate command that produced it. Check out our docs on driver sessions for more info. In the provided code, each client creates a new implicit session to run the find command. Subsequent getMore commands will reuse those same session IDs, though, not necessarily the ones associated with its cursor. When a getMore uses the concurrent thread's session ID, it causes the error you're experiencing. There's a couple of solutions to this: each client could start an explicit session, or you could use a mongocxx::cursor. Operations on a mongocxx::cursor will use the same session ID. |
| Comment by Clyde Bazile III (Inactive) [ 16/Nov/20 ] |
|
Hi Malik, Thanks for reporting this issue. We will look into this soon. |