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

To prevent dangling index records, CollectionBulkLoaderImpl should not call _addDocumentToIndexBlocks in a writeConflictRetry block.

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.0-rc2, 4.3.1
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • v4.2, v4.0
    • Repl 2019-06-17, Repl 2019-07-01
    • 0

      For uncapped collections, CollectionBulkLoaderImpl::insertDocuments inserts documents by calling CollectionImpl::insertDocumentForBulkLoader in a writeConflictRetry block. Regardless of this new batching design approach, it can lead to dangling index record entries. Consider, insertDocumentForBulkLoader() throws WriteConflictException. This leads to retrying of below operations.

      • Record insertion
      • Inserting <Index key, RecordId> pair into external sorter.

      Since inserting <Index key, RecordId> pair into external sorter is not part of storage transaction, previously failed storage transaction attempt would leave dangling index entries pointing to invalid RecordIds.

      The solution to fix this bug is that we should not wrap the  _addDocumentToIndexBlocks() method in a writeConflictRetry block.And, _addDocumentToIndexBlocks (insertion into external sorter) should be called only after the batch of records got successfully committed in the storage

            Assignee:
            allison.easton@mongodb.com Allison Easton
            Reporter:
            suganthi.mani@mongodb.com Suganthi Mani
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: