[SERVER-35758] Mongo shell prompt errors when running transactions after overriding "db" Created: 22/Jun/18 Updated: 29/Oct/23 Resolved: 10/Jul/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Replication, Shell |
| Affects Version/s: | None |
| Fix Version/s: | 4.0.1, 4.1.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Spencer Brody (Inactive) | Assignee: | Siyuan Zhou |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Backport Requested: |
v4.0
|
||||||||
| Sprint: | Repl 2018-07-02, Repl 2018-07-16 | ||||||||
| Participants: | |||||||||
| Description |
|
| Comments |
| Comment by Githook User [ 13/Jul/18 ] | |||||||||||
|
Author: {'username': 'visualzhou', 'name': 'Siyuan Zhou', 'email': 'siyuan.zhou@mongodb.com'}Message: (cherry picked from commit bb9f225e47faacb95ae9e5658313a5ebf56f37bf) | |||||||||||
| Comment by Githook User [ 10/Jul/18 ] | |||||||||||
|
Author: {'username': 'visualzhou', 'name': 'Siyuan Zhou', 'email': 'siyuan.zhou@mongodb.com'}Message: | |||||||||||
| Comment by Siyuan Zhou [ 22/Jun/18 ] | |||||||||||
|
alyson.cabral, updated the title. | |||||||||||
| Comment by Alyson Cabral (Inactive) [ 22/Jun/18 ] | |||||||||||
|
Can we update the title of the ticket to reflect the scope of this bug? spencer | |||||||||||
| Comment by Bruce Lucas (Inactive) [ 22/Jun/18 ] | |||||||||||
|
Reassigning db is a tempting thing to do given the session API (as the example illustrates). If this is dangerous is there some way we can prevent it? | |||||||||||
| Comment by Andy Schwerin [ 22/Jun/18 ] | |||||||||||
|
The problem stems from the user assigning a "session bound" Database object to the global "db" variable, which is consulted by shell prompt generators. spencer pointed out in person that we could adjust the environment in which the prompt is generated to always have a regular, session-less Database object during prompt generation. This seems like it would be nice to have, but users aren't really expected to override the "db" object in the interactive shell, and a lot of other surprising things might result. | |||||||||||
| Comment by Kay Kim (Inactive) [ 22/Jun/18 ] | |||||||||||
|
FYI – the error doesn't occur if you don't override the db object in the shell:
And in our txn docs, all our mongo shell examples get the collection instead of db:
| |||||||||||
| Comment by Spencer Brody (Inactive) [ 22/Jun/18 ] | |||||||||||
|
It looks like the issue that for the shell's interactive mode we try to run isMaster/replSetGetStatus to provide information to the prompt, and in doing so we send the isMaster with the transaction arguments including 'startTransaction', so when we get to the first real transaction command, we assume it's the second or third statement in the transaction and thus don't attach 'startTransaction' and then get the NoSuchTransaction error. |