In the .NET Driver's build matrix, we get sporadic failures when running a test related to map/reduce outputting to a collection. Sometimes our test runs go completely fine, and other times we'll get 2 or 3 failures of this across 2.4, 2.6, and 2.7 nightlies. This also only happens on sharded systems. It seems completely random. I have managed to grab log files from the mongo from 2.4 runs and 2.7 nightly runs, but haven't been able to reproduce with 2.6 yet (although the failure has occured).
The following test is what is being run:
[Test] [RequiresServer] public async Task ExecuteAsync_should_return_expected_result() { await DropCollectionAsync(); await InsertAsync( new BsonDocument { { "_id", 1 }, { "x", 1 }, { "v", 1 } }, new BsonDocument { { "_id", 2 }, { "x", 1 }, { "v", 2 } }, new BsonDocument { { "_id", 3 }, { "x", 2 }, { "v", 4 } }); var query = new BsonDocument(); var mapFunction = "function() { emit(this.x, this.v); }"; var reduceFunction = "function(key, values) { var sum = 0; for (var i = 0; i < values.length; i++) { sum += values[i]; }; return sum; }"; var subject = new MapReduceOutputToCollectionOperation(_collectionNamespace, _outputCollectionNamespace, mapFunction, reduceFunction, query, _messageEncoderSettings); var expectedDocuments = new BsonDocument[] { new BsonDocument { {"_id", 1 }, { "value", 3 } }, new BsonDocument { {"_id", 2 }, { "value", 4 } }, }; var response = await ExecuteOperationAsync(subject); response["ok"].ToBoolean().Should().BeTrue(); var documents = await ReadAllFromCollectionAsync(_outputCollectionNamespace); documents.Should().BeEquivalentTo(expectedDocuments); }