yii2-mongodb | Yii 2 MongoDB extension | Web Framework library
kandi X-RAY | yii2-mongodb Summary
kandi X-RAY | yii2-mongodb Summary
Yii 2 MongoDB extension
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Update the file .
- Update an item .
- Returns a substring from the file
- Load messages from database .
- Get migration history .
- Write session data .
- Process data .
- Execute a batch operation .
- Builds a IN condition .
- Returns the first column of the result set .
yii2-mongodb Key Features
yii2-mongodb Examples and Code Snippets
Community Discussions
Trending Discussions on yii2-mongodb
QUESTION
Currently I'm working on a new task manager that can create/fork new processes and execute given tasks from the database.
This is part of a php(7.4.18 custom built) project with mongodb(4.2 database, 1.9.1 php extension, 1.5.2 mongodb/mongodb wrapper package and 2.1.11 yiisoft/yii2-mongodb wrapper package)
So the way it works is that I'm pooling the database in every X seconds and if I can see at least 1 task then I get it in the parent process, then if there is enough free memory for a new task, then I fork the process (with pcntl) and execute the task in the child process.
The problem is that I get an error message in the logs, saying: Failure during socket delivery: Broken pipe (32)
Now what I think is that it might be because forking copies the memory stack of the parent process, and then both the parent and all the child processes are trying to use the exact same connection to the database. And once one of the child process finishes it exits and closes the connection, which - since it's used by all the processes - will be unavailable for the other processes.
I think mine isn't a unique case, so I would like to know how to solve this issue?
I've found a few previous bug reports:
But I'm not sure what is the official best way to go around this.
...ANSWER
Answered 2021-Jun-23 at 20:10You should be creating a new client instance from the process where you are using it.
See here for how this generally is supposed to work, and here if you are in an environment where you cannot easily create a new client instance.
Forking in php isn't very common as far as I know, so you should figure out whether you can create new clean slate clients in your child processes and do that if possible, otherwise handle the error and reconnect.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install yii2-mongodb
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page