Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-623

Retried commands may not consider wire version changes

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      For context, this concern came out of this PR comment for SPEC-1780.

      3b. Sending an equivalent command for the second attempt? in the Retryable Reads spec allows drivers to do one of two things when retrying a command:

      • If the wire version changes between retry attempts, the driver can recreate the command document according to the wire version of the server selected for the retry attempt. Any error in doing so should result in skipping the retry attempt and raising the original error.
      • If the driver doesn't recreate command documents, it can raise an error whenever the wire version dips between retry attempts.

      With respect to the second option: the spec does not talk about the wire verison increasing between retry attempts (e.g. option was supported but is no longer supported). This is admittedly an edge case, and were it to happen I think we can safely assume that a more recent server version would strictly validate commands and raise an validation error (loud error in this case good/safe).

      In PHPC and PHPLIB insert/update/delete commands are routed through _mongoc_write_command_execute_idl in libmongoc, which tracks option usage and raises errors if an option may be unsupported by a newly selected server for a retry attempt.

      All other commands are routed through libmongoc's generic R/W-aware command runners, which will use either _mongoc_client_retryable_write_command_with_stream or _mongoc_client_retryable_read_command_with_stream. Neither of those functions inspect options (and I wouldn't expect them to), so I presume we do not following the rules in the Retryable Reads spec. We neither recreate the command based on the second server's wire version, nor do we raise errors if the wire version dips. The original command is sent as-is.

      Although the Retryable Writes spec does not currently have language comparable to the aforecited section in the Retryable Reads spec, this may also be a concern for findAndModify. That is the only retryable write command that uses the _mongoc_client_retryable_write_command_with_stream code path.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: