mongo-php-driver: Persistent connections don't persist

I turned on mongodb.debug and I see such output from an apache request:

[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Connection string: 'mongodb://my.database.host:27017/database'
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Creating Manager, phongo-1.1.2[stable] - mongoc-1.3.2(1.3.2), libbson-1.3.2(1.3.2), php-5.4.15
[2016-03-31T09:42:49+00:00]     client: DEBUG   > Using custom stream initiator.
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Connecting to 'my.database.host:27017[mongodb://my.database.host:27017/database]'
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Created: RSRC#739 as 'my.database.host:27017[mongodb://my.database.host:27017/database]'
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 0
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 0
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 4 wanted: 0
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 0
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 376 wanted: 0
[2016-03-31T09:42:49+00:00] PHONGO-BSON: TRACE   > encoding document
[2016-03-31T09:42:49+00:00]    cluster: INFO    > SCRAM: authenticating "user" (step 1)
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 4 wanted: 4
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 191 wanted: 191
[2016-03-31T09:42:49+00:00]    cluster: INFO    > SCRAM: authenticating "user" (step 2)
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 4 wanted: 4
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 120 wanted: 120
[2016-03-31T09:42:49+00:00]    cluster: INFO    > SCRAM: authenticating "user" (step 3)
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 4 wanted: 4
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 90 wanted: 90
[2016-03-31T09:42:49+00:00]    cluster: INFO    > SCRAM: "user" authenticated
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 4 wanted: 4
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 32 wanted: 32
[2016-03-31T09:42:49+00:00] PHONGO-BSON: TRACE   > encoding document
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 4 wanted: 4
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Setting timeout to: 300000
[2016-03-31T09:42:49+00:00]     PHONGO: DEBUG   > Reading got: 882 wanted: 882

// some other operations

[2016-03-31T09:42:51+00:00]     PHONGO: DEBUG   > Not destroying RSRC#-1

As I see in php_phongo.c:717 library really does not want to destroy an existing resource, because it wants it to persist. But at this method the process has the resource id -1, which says “oops, the stream has already been destroyed”.

I could not figure out myself, how this can happen, hope you guys can.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

1.2.0alpha2 has been released, which includes significant changes to our connection handling and persistence. We’ve entirely dropped PHP’s streams API and now rely on libmongoc for all socket communication, which I expect may resolve a number of outstanding connection handling and timeout issues.

@minenok-tutu, @franek, @isegal: Please attempt reproducing your original problems with 1.2.0alpha2 and let us know if the issue persists. Thanks!

@jmikola sorry for the delay 😉 Problem is solved on my side with 1.2.2 (I didn’t try 1.2.0 or 1.2.1). 👍