Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP_QUERY deprecated in MongoDB 5.0 #19

Open
ErikUniformAgri opened this issue Apr 22, 2022 · 10 comments
Open

OP_QUERY deprecated in MongoDB 5.0 #19

ErikUniformAgri opened this issue Apr 22, 2022 · 10 comments

Comments

@ErikUniformAgri
Copy link

See https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/
Is there a work around or are there plans in the near future to implement an other way (like OP_MSG for example)?

@synopse
Copy link

synopse commented Aug 4, 2022

Support of those queries have been removed since 5.1/6.0. So we can't connect to any new version of MongoDB with this driver.
OP_MSG needs to be used for all communication, and will replace all other OP_* opcodes with commands, like find insert etc...
So it needs a deep rewrite of the code.

@tuurke63
Copy link

tuurke63 commented Aug 23, 2022

My fork of this library supports the new wire protocol. And yes, it was a pretty big rewrite. I've removed the old wire protocol because it stood in the way of new developments.

https://github.com/tuurke63/DelphiMongoDB

@ErikUniformAgri
Copy link
Author

It looks like it is connected, but I do net get a valid cursor when I try to find some records.

I get this error:
'{ "topologyVersion" : { "processId" : { "$oid" : "6304fbe8ba7dbc0714847ead" }, "counter" : 4 }, "ok" : 0.0, "errmsg" : "not master and slaveOk=false", "code" : 13435, "codeName" : "NotPrimaryNoSecondaryOk", "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1661331535, "i" : 14 } }, "signature" : { "hash" : { "$binary" : "3yc76Mym7HOwj/Jn2bzPI67uwqA=", "$type" : "00" }, "keyId" : 7079833891841769485 } }, "operationTime" : { "$timestamp" : { "t" : 1661331535, "i" : 14 } } }'

Do not know if it has anything to do with OP_MSG or connecting in general.
I try to connect to a secure replicaset with 3 slaves. Does anyone know if (and how I can connect to a replicaset?)

@tuurke63
Copy link

I'll probably have to take a look at the various flag bits that were used in the old OP_QUERY protocol etc and see how these "translate" into OP_MSG.

I use my forked version for connecting with MongoDB Community edition 6 and it works fine for me. Grijjy's unit tests run without errors. I haven't tested with Atlas or encryption.

@tuurke63
Copy link

tuurke63 commented Aug 25, 2022

@ErikUniformAgri

Do not know if it has anything to do with OP_MSG or connecting in general. I try to connect to a secure replicaset with 3 >slaves. Does anyone know if (and how I can connect to a replicaset?)

in my forked version (https://github.com/tuurke63/DelphiMongoDB), the tgoMongoProtocol and tgoMongoClient classes have a new property "globalReadPreference" that propagates to all tgoMongoDB and tgoMongoCollection objects created afterwards. You can override that setting for individual databases and collections using the ReadPreference property in tgoMongoDB and tgoMongoCollection.

@dbcto
Copy link
Contributor

dbcto commented Aug 29, 2022

Hi, we have implemented a few features for replica sets like GetInstanceInfo and IsMaster. The changes are available in the Grijjy master. But I'm not sure if we have to make changes for the new wire protocol?!

@tuurke63
Copy link

See: https://github.com/mongodb/specifications/blob/master/source/message/OP_MSG.rst#global-command-arguments

OP_MSG supports two new "global command arguments" ($db and $readPreference) in each message. If I understand correctly, this allows for fine-grained control: You can query the master for collection1, a secondary server on collection2 etc. In that respect, it is useful to have a "readPreference" property on each individual object (db, collection etc).

I created my fork of DelphiMongoDB for the needs of a project our company is developing (it will keep me busy for many years) and I now ask myself how to proceed further.

Should I do a merge request or diverge permanently?

I could do a merge request, but I suspect it will take Grijjy a lot of time to review my changes. The last time Grijjy actually performed any merge request in this repository is a year ago. And there is still a lot of missing MongoDB stuff I'd like to implement.

@grijjy
Copy link
Owner

grijjy commented Aug 29, 2022

I have examined and tested tuurke's fork to the library and greatly appreciate all the changes you, and others, have made. As noted, in order to support OP_MSG and/or remove OP_QUERY it requires a significant refactoring and rewrite of the base Grijjy MongoDB driver. This particular repository was never meant as an exhaustive implementation of the MongoDB driver, only an example to build upon since the full effort could take a significant amount of time, as you noted. I would suggest that tuurke's fork be diverged and considered the version which supports the new "standard" protocol.

@tuurke63
Copy link

Hi Griijjy (and others), I am not a very experienced Git user, what is the "proper" way to diverge a fork permanently ?

I'd like the users to be able to open issues and merge requests etcetera in the fork without disturbing your original repository.

@dbcto
Copy link
Contributor

dbcto commented Aug 30, 2022

...okay, we have to port it to the new hello command (https://www.mongodb.com/docs/manual/reference/command/hello/).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants