-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.2.10
-
Component/s: None
-
None
-
Environment:OS: 13.6.7 (22G720)
node.js / npm versions:
Additional info:
mongosh version 2.2.10
-
3
-
None
-
Developer Tools
Problem Statement/Rationale
When starting a transaction and redefining the db variable, tabcomplete throws an error
foo [direct: primary] test> se = db.getMongo().startSession({retryWrites: true, causalConsistency: true})
{ id: UUID("985d5844-8de9-4c87-a136-fc5dc2346989") }
foo [direct: primary] test> se.startTransaction()
foo [direct: primary] test> db = se.getDatabase("mongo");
mongo
foo [direct: primary] mongo> version()
2.2.10
foo [direct: primary] mongo> db.versTab completion error: MongoTransactionError: Read preference in a transaction must be primary, not: primaryPreferred
at t.executeOperation (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3597310)
at ListCollectionsCursor._initialize (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3511674)
at [kInit] (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3499898)
at v (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3500522)
at ListCollectionsCursor.next (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3497824)
at [Symbol.asyncIterator] (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3496931)
at AsyncGenerator.next (<anonymous>)
at ListCollectionsCursor.toArray (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:3:3498293)
at CliServiceProvider.listCollections (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:213:205759)
at Proxy._listCollections (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:213:305405) {
[Symbol(errorLabels)]: Set(0) {}
}
Please be sure to attach relevant logs with any sensitive data redacted.
n/a?
Steps to Reproduce
see above
Expected Results
I get a tab completion (or list of options) for the command I want
Actual Results
Stack trace as shown above
Additional Notes
As per Anna H in this slack convo
Did you assign db = ... before, as part of starting a transaction? I think that would reset the autocompletion cache for database/collection names, so autocompleting anything would try to refresh that cache, which runs listCollections/listDatabases with primaryPreferred (that's mongosh's choice, we set it explicitly for these commands)
Definitely not expected behavior, though, so MONGOSH ticket is probably the way to go