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

Allow hint for unacknowledged writes using OP_MSG when supported by the server

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.10.0
    • Affects Version/s: None
    • Component/s: Spec Comp
    • Labels:
      None
    • Hide

      DRIVERS-1340:
      Drivers should no longer prohibit using hint with an unacknowledged write concern for update, delete, and findAndModify commands (issued via OP_MSG) and related helpers (e.g. UpdateOne, bulkWrite, findOneAndDelete) if hint is known to be supported by the server executing the operation (i.e. 4.2+ for update commands, 4.4+ for delete and findAndModify). Drivers should sync unified CRUD tests with mongodb/specifications@59a5dad

      Drivers (like Java, for example) that ignore unacknowledged write concern for findOneAndReplace/Update/Delete helpers should skip the following tests:

      • Unacknowledged findOneAndReplace with hint string on 4.4+ server
      • Unacknowledged findOneAndReplace with hint document on 4.4+ server
      • Unacknowledged findOneAndUpdate with hint string on 4.4+ server
      • Unacknowledged findOneAndUpdate with hint document on 4.4+ server
      • Unacknowledged findOneAndDelete with hint string on 4.4+ server
      • Unacknowledged findOneAndDelete with hint document on 4.4+ server

      because those tests are assuming that the driver includes writeConcern: {w : 0 } in the findAndModify command and that, as a result, the server response with only ok: 1 and therefore value is unset.

      Show
      DRIVERS-1340 : Drivers should no longer prohibit using hint with an unacknowledged write concern for update, delete, and findAndModify commands (issued via OP_MSG) and related helpers (e.g. UpdateOne, bulkWrite, findOneAndDelete) if hint is known to be supported by the server executing the operation (i.e. 4.2+ for update commands, 4.4+ for delete and findAndModify). Drivers should sync unified CRUD tests with mongodb/specifications@59a5dad Drivers (like Java, for example) that ignore unacknowledged write concern for findOneAndReplace/Update/Delete helpers should skip the following tests: Unacknowledged findOneAndReplace with hint string on 4.4+ server Unacknowledged findOneAndReplace with hint document on 4.4+ server Unacknowledged findOneAndUpdate with hint string on 4.4+ server Unacknowledged findOneAndUpdate with hint document on 4.4+ server Unacknowledged findOneAndDelete with hint string on 4.4+ server Unacknowledged findOneAndDelete with hint document on 4.4+ server because those tests are assuming that the driver includes writeConcern: {w : 0 } in the findAndModify command and that, as a result, the server response with only ok: 1 and therefore value is unset.

      Downstream changes: Drivers should no longer prohibit using hint with an unacknowledged write concern for update, delete, and findAndModify commands (issued via OP_MSG) and related helpers (e.g. UpdateOne, bulkWrite, findOneAndDelete) if hint is known to be supported by the server executing the operation (i.e. 4.2+ for update commands, 4.4+ for delete and findAndModify). Drivers should sync unified CRUD tests with mongodb/specifications@59a5dad


      This reverts DRIVERS-991, which instructed drivers to raise a client-side error when the hint option is provided with an unacknowledged write issued against any server version.

      When the the server is known to support hint (i.e. 4.2+ for update, 4.4+ for delete), drivers should allow the option to be specified. They should only report an error for earlier server versions where the server is known to not support the option and an error would otherwise not be returned because of the nature of unacknowledged writes.

      Previous arguments relating hint to existing treatment of arrayFilters and collation aren't relevant, because their documentation refers to "unacknowledged writes using OP_UPDATE" (where the option cannot be expressed). Those options don't refer to OP_MSG at all, because they were both supported by all server versions that support OP_MSG. hint can retain the language about OP_UPDATE, but its OP_MSG language should be revised to only mandate an error on unsupported server versions.

      Lastly, the following Q&A should be revised:

      Q: Why are client-side errors raised when options are provided for unacknowledged write operations, even on server versions that support those options?
      Even if the server supports an option, that option could be incorrectly formatted or contain outdated information (e.g. a "hint" option referencing an index that no longer exists). This is a problem during unacknowledged writes because the server cannot return an error response to alert the client of an incorrect option. By always raising a client-side error when options are specified for unacknowledged writes, users are prevented from performing operations with options that do not work.

      This is a poor argument as incorrectly formatted options can just as easily apply to the filter or update/replacement arguments (e.g. using an invalid query operator). It's one thing to raise a client-error when the driver knows for certain that a server option is not supported, but the current strategy is presumptive.

      We should also update the language for findAndModify in the CRUD spec (since it does refer to behavior of unacknowledged write concerns). findAndModify support for hint requires 4.4+ (see: SERVER-42099, SERVER-44367). Although findAndModify always returns a response, an unacknowledged write concern seems to force an {{

      {ok:1}

      }} response, which hides any error if hint is unsupported or invalid (e.g. no such index). With respect to this issue, we need only concern ourselves with whether hint is supported, so raising an error if hint is used on a pre-4.4 server with an unacknowledged write concern is sufficient.


      Summary

      This issue was originally reported after starting work on language tickets for DRIVERS-991, which asked drivers to raise client-side errors for any use of hint with unacknowledged writes. This ticket seeks to revert that change and make an allowance for cases where drivers know that the server does support the hint option. Since DRIVERS-991 was filed, libmongoc and dependent drivers have chosen not to implement that ticket and are instead waiting on this ticket to be resolved. This ticket has languished for more than a year since and remains outstanding.

      Motivation

      Who is the affected end user?

      Applications that would like to utilize hint options with unacknowledged writes.

      How does this affect the end user?

      The behavior is currently prohibited by our specifications despite being possible to implement. In hindsight, it was premature to add the blanket prohibition.

      How likely is it that this problem or use case will occur?

      A minority of applications make individual use of hint and unacknowledged writes. The intersection of applications using both features together is even rarer.

      If the problem does occur, what are the consequences and how severe are they?

      Inability to execute a supported operation.

      Is this issue urgent?

      No.

      Is this ticket required by a downstream team?

      No.

      Is this ticket only for tests?

      This ticket affects both driver functionality and our spec tests.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: