Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-2877

Fix racy unified tests of unacknowledged writes

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Component/s: CRUD
    • Labels:
      None
    • Needed - No Spec Changes
    • Hide

      Summary of necessary driver changes

      • Sync command logging and monitoring tests for unacknowledged writes.
      • Note that these might be the first logging tests that utilize ignoreExtraMessages, so that test runner feature may need to be implemented before being able to run the updated logging test. Implementation should be similar to existing ignoreExtraEvents.

      Commits for syncing spec/prose tests
      (and/or refer to an existing language POC if needed)

      Context for other referenced/linked tickets

      •  N/A

      Notes

      Syncing these tests should be considered low priority unless you're seeing similar failures to the ones described in the ticket description.

      Show
      Summary of necessary driver changes Sync command logging and monitoring tests for unacknowledged writes. Note that these might be the first logging tests that utilize ignoreExtraMessages , so that test runner feature may need to be implemented before being able to run the updated logging test. Implementation should be similar to existing ignoreExtraEvents . Commits for syncing spec/prose tests (and/or refer to an existing language POC if needed)   https://github.com/mongodb/specifications/commit/cd08b7248eb4e3ab901a8f7905874da41b908f7c Context for other referenced/linked tickets  N/A Notes Syncing these tests should be considered low priority unless you're seeing similar failures to the ones described in the ticket description.
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      CDRIVER-5519 Backlog
      CXX-2997 Backlog
      CSHARP-5020 Backlog
      GODRIVER-3171 Backlog
      JAVA-5398 Fixed 5.1.0
      NODE-6061 Backlog
      MOTOR-1290 Duplicate
      PYTHON-4322 Fixed 4.7
      PHPLIB-1424 Fixed 1.19.0
      RUBY-3431 Backlog
      RUST-1901 Won't Do
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } Key Status/Resolution FixVersion CDRIVER-5519 Backlog CXX-2997 Backlog CSHARP-5020 Backlog GODRIVER-3171 Backlog JAVA-5398 Fixed 5.1.0 NODE-6061 Backlog MOTOR-1290 Duplicate PYTHON-4322 Fixed 4.7 PHPLIB-1424 Fixed 1.19.0 RUBY-3431 Backlog RUST-1901 Won't Do

      Unified tests of unacknowledged (w: 0) are inherently racy. Consider two contiguously executed tests of acknowledged writes to the same collection, and the order of operations is predictably

      1. drop db.coll (start of first test)
      2. create db.coll
      3. insert into db.coll
      4. drop db.coll (start of second test)
      5. create db.coll
      6. insert into db.coll

      But if the first insert is unacknowledged, the order could be

      1. drop db.coll (start of first test)
      2. create db.coll
      3. drop db.coll (start of second test)
      4. insert into db.coll (leftover from first test!)
      5. create db.coll
      6. insert into db.coll

      In which case the second create command will fail with a NamespaceExists error, because the collection drop from the second test ends up happening before the insert from the first test, so the collection is implicitly recreated by the insert.

      This is not just a theoretical problem, as we're seeing this fairly regularly in the Java driver. The particular case is with the unified command monitoring tests. The A successful updateMany test fails with a NamespaceExists error, which is immediately preceded by the A successful unordered bulk write with an unacknowledged write concern test. Note that both tests use the same namespace (command-monitoring-tests.test).

      The simplest workaround for this raciness is probably to just use a unique namespace for any tests of unacknowledged writes, but I'm open to other solutions.

      Update

      After discussion in the comments, a better approach is to force completion of the unacknowledged write by following it with an acknowledged operation, such as a find. Since connection pool size defaults to 1, the next operation will use the same connection, and won't complete until after completion of the unacknowledged write. And by using a find, we can assert this behavior by expecting the inserted documents from the unacknowledged write in the find command results.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: