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

MongoDB extension support #145

Open
ShockedPlot7560 opened this issue Sep 3, 2022 · 8 comments
Open

MongoDB extension support #145

ShockedPlot7560 opened this issue Sep 3, 2022 · 8 comments

Comments

@ShockedPlot7560
Copy link
Member

This binary contains direct support for mysql and sqlite however as soon as we want to use another database such as mongo, it is mandatory to create our own fork and to modify it ourselves.

Seeing the increasing demand for this extension, I think it would be a good idea to add it. In any case, it is always possible to disable it in the php.ini

@AkmalFairuz
Copy link

I don't recommend to use MongoDB in PM server.

The extension was designed for web application, the MongoDB connection will close after the script end. There is no way to close the Mongo connection like mysqli_close($conn) (this will cause memory leak) unless you're using the old Mongo extension.

mongodb/mongo-php-library#600

@SOF3
Copy link
Member

SOF3 commented Sep 22, 2022

would it be better to access mongodb with a userspace library instead?

@dktapps
Copy link
Member

dktapps commented Sep 22, 2022

I don't recommend to use MongoDB in PM server.

The extension was designed for web application, the MongoDB connection will close after the script end. There is no way to close the Mongo connection like mysqli_close($conn) (this will cause memory leak) unless you're using the old Mongo extension.

mongodb/mongo-php-library#600

I don't think this is a concern. The reason they implemented it like this is so that different PHP web requests can reuse the same client without having to reestablish connections. In the PM context, every thread is a request.

Unless you have a habit of establishing large numbers of MongoDB connections to many different databases, I don't really think this is a problem.

@SOF3
Copy link
Member

SOF3 commented Sep 22, 2022

so is the mongodb instance freed when a thread exits? if that is the case, it sounds reasonable.

@dktapps
Copy link
Member

dktapps commented Sep 23, 2022

So far as I understand, no. But in any case, I don't think it matters.

@SOF3
Copy link
Member

SOF3 commented Sep 23, 2022

For example, in terms of network errors, would it still leak a resource even though connection breaks?

@ShockedPlot7560
Copy link
Member Author

In any case, it is up to the developer in this case to pay attention to all the tools he uses and to get informed about them.
Simply, at the moment, the only way to use a db mongo is either to find a wobbly fork with the extension, or to change DB.

@SOF3
Copy link
Member

SOF3 commented Jan 11, 2023

Note that the use of mongodb itself is highly controversial due to its lack of consistency in its opinionated preference over simplicity.

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

Successfully merging a pull request may close this issue.

4 participants