-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3472 - Add log messages to SDAM spec #1771
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
Conversation
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.
Overall LGTM!
Left non-blocking comments.
@@ -16,7 +16,7 @@ | |||
"b:27017" | |||
], | |||
"minWireVersion": 0, | |||
"maxWireVersion": 21 | |||
"maxWireVersion": 6 |
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.
Guessing this is just a spec requirement change?
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.
Yes.
@@ -1804,14 +1818,28 @@ def check_events(self, spec): | |||
else: | |||
assert server_connection_id is None | |||
|
|||
def process_ignore_messages(self, ignore_logs, actual_logs): | |||
final_logs = [] | |||
for log in actual_logs: |
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.
NIT: Thoughts on this potential optimization?
actual_log_messages = {actual_log["data"]["message"] for actual_log in actual_logs}
return list(filter(lambda log: log["data"]["message"] not in actual_log_messages))
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.
I like this optimization but it does deviate from the spec's statement that "Matching rules used to match messages in ignoreMessages
are identical to match rules used for messages
matching". Is this a case where we need to stick closely to the spec, or can we do this much simpler way of matching?
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.
Good point. I'll say let's not then.
The self.match_evaluator.match_result()
function could be added in, but we lose readability so we'll keep it as is.
Co-authored-by: Jib <Jibzade@gmail.com>
Co-authored-by: Jib <Jibzade@gmail.com>
pymongo/asynchronous/monitor.py
Outdated
if self._publish: | ||
assert self._listeners is not None | ||
sd = self._server_description | ||
# XXX: "awaited" could be incorrectly set to True in the rare case | ||
# the pool checkout closes and recreates a connection. |
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.
This comment should move along with the awaited
var.
pymongo/synchronous/monitor.py
Outdated
serverHost=address[0], | ||
serverPort=address[1], | ||
awaited=awaited, | ||
durationMS=round_trip_time, |
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.
Here and elsewhere: round_trip_time is a float in seconds, but durationMS should be in milliseconds.
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.
Still need to make this change in the other locations where durationMS is passed.
pymongo/asynchronous/monitor.py
Outdated
serverHost=address[0], | ||
serverPort=address[1], | ||
awaited=awaited, | ||
durationMS=duration, |
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.
durationMS needs to be in ms here too.
self._listeners.publish_server_heartbeat_started(address, awaited) | ||
|
||
if self._cancel_context and self._cancel_context.cancelled: | ||
await self._reset_connection() | ||
async with self._pool.checkout() as conn: | ||
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): |
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.
Shouldn't this happen at the same point where publish_server_heartbeat_started is called?
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.
In theory yes. However, we need a connection for the required logging information, and checking out the connection before publishing the heartbeat has a lot of side effects for other tests.
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.
I would expect driverConnectionId to be None on the initial started event. Does the spec not expect that?
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.
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 this was intended to be fixed in DRIVERS-2677. Let's go forward with the current approach for now since the spec is ambiguous.
@@ -1804,14 +1818,28 @@ def check_events(self, spec): | |||
else: | |||
assert server_connection_id is None | |||
|
|||
def process_ignore_messages(self, ignore_logs, actual_logs): | |||
final_logs = [] | |||
for log in actual_logs: |
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.
Good point. I'll say let's not then.
The self.match_evaluator.match_result()
function could be added in, but we lose readability so we'll keep it as is.
Is this pypy failure related?:
|
I wouldn't expect it to be related, but it doesn't appear to be failing on other PRs. According to the logging docs, |
I cannot reproduce this locally. Will keep an eye on it, and if it continues failing I'll open a ticket to investigate. |
No description provided.