[SERVER-38631] Restore entire state of a session in the shell if a node is restarted Created: 14/Dec/18 Updated: 29/Oct/23 Resolved: 24/Jan/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Testing Infrastructure |
| Affects Version/s: | None |
| Fix Version/s: | 4.1.8 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Samyukta Lanka | Assignee: | Siyuan Zhou |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | prepare_testing | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | Repl 2019-01-28 | ||||||||
| Participants: | |||||||||
| Description |
|
If we restart a node that had an active session, the shell starts a new session instead of restoring the state of the old session. This means that if we were running a prepared transaction before the restart, we can't call commitTransaction or abortTransaction without the shell returning an error saying that there is no active transaction on the session. For now, we've been using a workaround to manually set the txnNumber and lsid so that we can get runCommand to work. However, we still can't run any other functions on the session and expect them to be run on the session we wanted (and we can't use the commitTransaction or abortTransaction functions, we have to use runCommand). It would be great to be able to restore the entire state of the session beyond just the txnNumber and lsid. This would be particularly useful for passthrough suites that do failover testing for prepared transactions. |
| Comments |
| Comment by Siyuan Zhou [ 24/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After the above commit, we should be able to create a delegating driver session from the one targeting to the old primary.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Siyuan Zhou [ 24/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
max.hirschhorn, closing the ticket. I'm happy to reopen this ticket or create a new ticket if you think we should remove the reference of client in the constructor of ServerSession as discussed in the code review. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 24/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'username': 'visualzhou', 'email': 'siyuan.zhou@mongodb.com', 'name': 'Siyuan Zhou'}Message: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Max Hirschhorn [ 24/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Yes, I think changing the endTransaction() function to call through to the SessionAwareClient would make the behavior of commands run internally by DriverSession API methods consistent with the behavior of commands run by a user.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Siyuan Zhou [ 24/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
max.hirschhorn, do you think we should make ServerSession call into the driver session to get the client? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Siyuan Zhou [ 20/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks max.hirschhorn, this is exactly what we need. Assigned to Repl team to merge your patch. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Max Hirschhorn [ 18/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
samy.lanka, siyuan.zhou, restarting a node involves constructing a new Mongo connection object and therefore creating a new chain of DriverSession, DB, and DBCollection objects. I'd expect DelegatingDriverSession to fit what you're interested in doing because you effectively want to use an existing DriverSession object with a different Mongo connection object than it was originally constructed with.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Siyuan Zhou [ 14/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This may also be useful to passthrough test suites. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Samyukta Lanka [ 14/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
max.hirschhorn Let us know if you think this would be feasible and worth the effort. |