[SERVER-38858] Fix race in blocking_results_merger_test Created: 04/Jan/19  Updated: 29/Oct/23  Resolved: 11/Jan/19

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.1.7

Type: Bug Priority: Major - P3
Reporter: Ian Boros Assignee: Ian Boros
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2019-01-14, Query 2019-01-28
Participants:
Linked BF Score: 0

 Description   

There is a race in ShouldBeAbleToBlockUntilNextResultIsReadyWithDeadline:



 Comments   
Comment by Githook User [ 11/Jan/19 ]

Author:

{'email': 'ian.boros@10gen.com', 'name': 'Ian Boros'}

Message: SERVER-38858 fix race
Branch: master
https://github.com/mongodb/mongo/commit/424621d33255e28cf5f4988935a0d175f6e9fd78

Comment by Ian Boros [ 05/Jan/19 ]

Notes to myself about this:

It's possible that the response to the getMore scheduled by this call to next() (see line 140) is already queued up, causing next() to return a document.

Specifically, the following order of events will cause this part of the test to fail:

1) the onCommand() on line 140 is run
2) blockingMerger.next() is entered on line 124 (does not complete yet)
2) BlockingResultsMerger::next() schedules the getMore: https://github.com/mongodb/mongo/blob/907c8c786e26414735892bfbe763cd67e7f7e7e4/src/mongo/s/query/blocking_results_merger.cpp#L86

4) The response to the getMore is processed and queued up by the network thread. The "event" returned by the code above is signaled
5) BlockingResultsMerger::next() waits for the event: https://github.com/mongodb/mongo/blob/907c8c786e26414735892bfbe763cd67e7f7e7e4/src/mongo/s/query/blocking_results_merger.cpp#L93-L94.

Since it's already been signaled, the document is available, so it is returned.

6) The assertion fails because next is not EOF.

Generated at Thu Feb 08 04:50:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.