Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36871

$sample can loop infinitely on orphaned data

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.7
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • v4.0, v3.6
    • Query 2018-10-08, Query 2018-11-19, Query 2018-12-03, Query 2018-12-17

      The following scenario (at least) can cause an infinite loop in $sample:

      1. A moveChunk command starts moving a chunk from shard0 to shard1
      2. $sample begins and a getMore targets shard1
      3. That getMore uses a cursor that samples randomly with replacement from WiredTiger
      4. That cursor only fetches one document because the sample size is one, and that document does not belong to that shard because it's in the chunk that's being moved from shard0 to shard1 and does not own it. The ShardFilterStage then filters that document and returns NEEDS_TIME
      5. The yielding policy is NO_YIELD for some reason so no yielding happens and it tries to sample the cursor again but gets the same document back. This happens infinitely. The yielding behavior may not affect the infinite loop in this case, but it's still unexpected so I'm including it here.

            Assignee:
            bernard.gorman@mongodb.com Bernard Gorman
            Reporter:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: