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
PHPC-1893: Implement SDAM event classes #1251
Conversation
…::getServerDescription() (mongodb#1239) Co-authored-by: Andreas Braun <git@alcaeus.org> Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
…ubscriber, and TopologyChangedEvent (mongodb#1244)
I just realized that the return types in the function header comments of
Should I just fix that here or make a separate PR? |
Separate PR makes sense. You can probably just edit it directly through GitHub, since it's within the same file: https://github.com/mongodb/mongo-php-driver/blob/feature/sdam-monitoring/src/MongoDB/Monitoring/TopologyChangedEvent.c |
$command = new MongoDB\Driver\Command(['ping' => 1]); | ||
$m->executeCommand(DATABASE_NAME, $command); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
- getHost() returns a string: yes | ||
- getPort() returns an integer: yes | ||
- getTopologyId() returns an ObjectId: yes | ||
===DONE=== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The monitoring-serverClosed-001.phpt
test fails on the GitHub CI (https://github.com/mongodb/mongo-php-driver/pull/1251/checks?check_run_id=3365180493) because I think no ServerClosedEvent
is emitted from the 'ping' command - how should I make sure that we get a server closed event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this test ever pass locally for you, or was CI the first time you observed it in action?
According to the SDAM Monitoring spec, ServerClosedEvent is:
Published when the server monitor’s connection is closed and the server is shutdown.
You may need to use the disableClientPersistence
driver option for Manager (third argument) to ensure the connection get closed when the manager object goes out of scope. Without that, the libmongoc client will outlive the Manager object.
While you're doing this, I'd also suggest using Manager::addSubscriber()
for this test (ahead of PHPC-1959). Offhand, I'm not sure if adding a subscriber on a specific Manager will add a reference to it, which might prevent it from being garbage collected (and thus the libmongoc client being destroyed due to disableClientPersistence
). I don't believe that's the case, as phongo_apm_copy_manager_for_client
may be the only place that is done (and only for the lifetime of the command monitoring events being dispatched). Using Manager::addSubscriber()
would allow us to confirm that's indeed the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, the test did pass locally for me but not on the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I added the disableClientPersistence
option but the test seems to fail for the same reason as before (https://github.com/mongodb/mongo-php-driver/pull/1251/checks?check_run_id=3374366170).
I can confirm that On a separate note, I observed something strange when running the test on a replica set. While trying to diagnose a possible failure, I modified the event subscriber to dump all events: class MySubscriber implements MongoDB\Driver\Monitoring\SDAMSubscriber
{
public function serverChanged(MongoDB\Driver\Monitoring\ServerChangedEvent $event) { var_dump($event); }
public function serverClosed(MongoDB\Driver\Monitoring\ServerClosedEvent $event) { var_dump($event); }
public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event) { var_dump($event); }
public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event) { var_dump($event); }
public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event) { var_dump($event); }
} I had a 4.4 replica set running locally and configured
The output for |
Should be fixed now - I had some extra lines in |
Notes: Currently the |
Per the spec, this is emitted when a Since setting the fail point requires connecting to the server, there are at least two ways to go about this:
|
b547493
to
f54b170
Compare
f1b6b03
to
b5d33b5
Compare
Superseded by #1287. |
https://jira.mongodb.org/browse/PHPC-1893