Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pymongo/asynchronous/client_bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ async def write_command(
bwc._fail(request_id, failure, duration)
# Top-level error will be embedded in ClientBulkWriteException.
reply = {"error": exc}
# Propagate $clusterTime to the caller.
if "$clusterTime" in cmd:
reply["$clusterTime"] = cmd["$clusterTime"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$clusterTime needs to be parsed from the (potential) server error response, not the command. We also need to do the same for operationTime.

This is the method that handles it, it probably makes more sense to call this method at a lower level if we can (perhaps in write_command):

client._process_response(command_response, session)

Or another alternative.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, updated.

finally:
bwc.start_time = datetime.datetime.now()
return reply # type: ignore[return-value]
Expand Down
3 changes: 3 additions & 0 deletions pymongo/synchronous/client_bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ def write_command(
bwc._fail(request_id, failure, duration)
# Top-level error will be embedded in ClientBulkWriteException.
reply = {"error": exc}
# Propagate $clusterTime to the caller.
if "$clusterTime" in cmd:
reply["$clusterTime"] = cmd["$clusterTime"]
finally:
bwc.start_time = datetime.datetime.now()
return reply # type: ignore[return-value]
Expand Down
Loading