Priority: Major - P3
Affects Version/s: 1.6.9
Fix Version/s: 1.6.10
Environment:This has been reproduced with both Mac OSX Yosemite and CentOS 6.
Last comment by Customer:true
Sprint:PHP Sprint 21
The PHP Mongo Driver version does not properly close cursors on the server if a limit was used, and there are more documents available (e.g. using a limit of 20 on a query that would return 30 documents). This issue was introduced in 1.6.0 and still persists in 1.6.9. In 1.5.8, the problem is not reproducible.
I am guessing this is related to the behavior where PHP is supposed to kill the cursor in the dtor (e.g. as referenced in https://jira.mongodb.org/browse/PHPC-225)
This is easily reproducible (see below steps) using MongoDB 2.6.10 server running on Mac OS via home-brew, but the same has been observed in our production servers running MongoDB 2.6.9 on CentOS 6. This was originally noticed in production when we upgraded from PHP Mongo Driver 1.5.4 to PHP Mongo Driver 1.6.9 on one test server, and then the MongoDB server showed an exponential growth in open cursors.
When reproduced locally in Mac OSX, it was a solo Mongod. In Production, it was a replica set with one primary, one secondary, and one arbiter. Most of our reads which use the limit option were secondary preferred, and so we saw the cursor count spike on the secondary, not the primary.
Aside: In production, having thousands of open cursors caused from this bug correlated to high spikes in lock % (up to 100% in some cases, whereas prior to this the spikes were never above 10%), which could make this issue much more serious. However, we have not been able to prove that causality, so the lock % rising may be unrelated.
Each execution of the above PHP script will increase the number of totalOpen cursors by 1. These cursors will persist until cursorTimeoutMillis has passed [and in production, our cursorTimeoutMillis is extremely high for other reasons].
I have tested this using the following versions:
1.6.9 - problem happens!
1.6.8 - problem happens!
1.6.3 - problem happens!
1.6.0 - problem happens!
1.5.8 - problem not reproducible
1.5.4 - problem not reproducible
This leads me to believe the problem was introduced in 1.6.0 and has not been fixed in the latest 1.6.9 version of the driver.