-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Component/s: Command Logging and Monitoring
-
None
-
Needed - No Spec Changes
-
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
- drop db.coll (start of first test)
- create db.coll
- insert into db.coll
- drop db.coll (start of second test)
- create db.coll
- insert into db.coll
But if the first insert is unacknowledged, the order could be
- drop db.coll (start of first test)
- create db.coll
- drop db.coll (start of second test)
- insert into db.coll (leftover from first test!)
- create db.coll
- 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.
- is related to
-
NODE-6063 Unified Runner Ignores ignoreExtraMessages
- Closed
-
JAVA-5361 w: 0 writes causing test failures
- Closed
- related to
-
DRIVERS-2921 Use single mongos in racy unacknowledged write tests
- Implementing
- split to
-
RUBY-3431 Fix racy unified tests of unacknowledged writes
- Backlog
-
CDRIVER-5519 Fix racy unified tests of unacknowledged writes
- Backlog
-
CXX-2997 Fix racy unified tests of unacknowledged writes
- Backlog
-
GODRIVER-3171 Fix racy unified tests of unacknowledged writes
- Backlog
-
CSHARP-5020 Fix racy unified tests of unacknowledged writes
- Closed
-
JAVA-5398 Fix racy unified tests of unacknowledged writes
- Closed
-
MOTOR-1290 Fix racy unified tests of unacknowledged writes
- Closed
-
NODE-6061 Fix racy unified tests of unacknowledged writes
- Closed
-
PHPLIB-1424 Fix racy unified tests of unacknowledged writes
- Closed
-
PYTHON-4322 Fix racy unified tests of unacknowledged writes
- Closed
-
RUST-1901 Fix racy unified tests of unacknowledged writes
- Closed