The test documentation.DocumentationSamples.testQueryingArrayValues failed in Evergreen for the build variant tests-jdk8-unsecure__version~4.4_os~linux_topology~replicaset_auth~noauth_ssl~nossl_jdk~jdk8: https://spruce.mongodb.com/task/mongo_java_driver_tests_jdk8_unsecure__version~4.4_os~linux_topology~replicaset_auth~noauth_ssl~nossl_jdk~jdk8_test_patch_d57dfa8af686180239058a06eca838e18bfe5cdd_605277f93e8e863987251298_21_03_17_21_43_22/tests?execution=0&page=0&sortBy=STATUS&sortDir=ASC with the following assertion error
This test is for the collection.insertMany code sample on the page https://docs.mongodb.com/manual/tutorial/query-arrays/.
The error happened despite documentation.DocumentationSamples doing collection.drop() synchronously in the @After tearDown method. The test class does the following:
The assertion relies on the following:
- drop is ordered before insertMany (monotonic writes)
- countDocuments observes insertMany (read your writes).
According to https://docs.mongodb.com/manual/core/causal-consistency-read-write-concerns/, RYW is guaranteed only if the majority write and read concerns are used. Thus, the test must use them. However, the lack of RYW in the test cannot explain observing 7 elements in the collection instead of 5, which violates the monotonic writes consistency. The problem here is that "MongoDB provides monotonic write guarantees, by default, for standalone mongod instances and replica set.", and the test failed for a replica set. I do not know how to explain the failure, but I think it is worth thinking about and discussing.