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

$sample can loop infinitely on orphaned data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.7
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Backport Requested:
      v4.0, v3.6
    • Sprint:
      Query 2018-10-08, Query 2018-11-19, Query 2018-12-03, Query 2018-12-17
    • Case:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bernard.gorman Bernard Gorman
              Reporter:
              matthew.saltz Matthew Saltz
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              14 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: