Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3910

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: libmongoc
    • Labels:
      None

      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.

      The Retryable Writes command has no equivalent language (see DRIVERS-1570), although this may still be a concern.

      AFAIK, libmongoc tracks hint usage for update/delete through _mongoc_write_command_execute_idl and would raise an error if it's not supported by the selected server's wire protocol version (for either the original or any retry attempt). For findAndModify, libmongoc handles its retrying within mongoc_collection_find_and_modify_with_opts and only appears to check hint support against the wire version of the originally selected server. Perhaps libmongoc relies on the selected server for the retry attempt to raise an error if it also receives hint and doesn't support the option.

      Any other retried commands would be read operations and route through _mongoc_client_retryable_read_command_with_stream. Neither that function nor its write equivalent (relevant for PHP, which uses the generic write command runner) inspects options (and I wouldn't expect them to). The onus for checking option support likely belongs in specific operation methods, as is done for mongoc_collection_find_and_modify_with_opts. Either way, it seems like libmongoc doesn't conform to the aforecited rules from the Retryable Reads spec. It neither recreates commands based on the second server's wire version, nor does it raise errors if the wire version dips. The original command is sent as-is.

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

              Created:
              Updated: