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

Invariant failure inserting document on replica set with depth equal to maxBSONDepth

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Execution Team 2021-10-04

      I started up a one-node replica set with maxBSONDepth=5 and attempted to insert document {a: {b: {c: {d: {e: {f: 1}}}}}} which is nested exactly five levels deep, and hit this (debug build-only) invariant. I tried the same thing with maxBSONDepth=6 and a document nested six levels deep, with the same result.

      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
      #1  0x00007f2bd7b9e8b1 in __GI_abort () at abort.c:79
      #2  0x00007f2bd9fb44fb in mongo::invariantFailed (expr=0x7f2bc40f8268 "validateBSON(data, len).isOK()",
          file=0x7f2bc40f8287 "src/mongo/db/record_id_helpers.cpp", line=73) at src/mongo/util/assert_util.cpp:121
      #3  0x00007f2bd9e593fc in mongo::invariantWithLocation<bool> (testOK=@0x7f2b91906957: false,
          expr=0x7f2bc40f8268 "validateBSON(data, len).isOK()", file=0x7f2bc40f8287 "src/mongo/db/record_id_helpers.cpp", line=73)
          at src/mongo/util/invariant.h:71
      #4  0x00007f2bc40efff6 in mongo::record_id_helpers::extractKeyOptime (data=0x7f2ba73ded68 "\263", len=179)
          at src/mongo/db/record_id_helpers.cpp:73
      #5  0x00007f2bbd68c3b1 in mongo::WiredTigerRecordStore::_insertRecords (this=0x7f2ba6ee0a20, opCtx=0x7f2ba77e8e20,
          records=0x7f2ba65e6b20, timestamps=0x7f2ba86ce9e0, nRecords=1)
          at src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp:1284
      #6  0x00007f2bbd68c085 in mongo::WiredTigerRecordStore::insertRecords (this=0x7f2ba6ee0a20, opCtx=0x7f2ba77e8e20,
          records=0x7f2b91907530, timestamps=std::vector of length 1, capacity 1 = {...})
          at src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp:1255
      #7  0x00007f2bcb25077b in mongo::CollectionImpl::insertDocumentsForOplog (this=0x7f2ba74decb0, opCtx=0x7f2ba77e8e20,
          records=0x7f2b91907530, timestamps=std::vector of length 1, capacity 1 = {...}) at src/mongo/db/catalog/collection_impl.cpp:598
      #8  0x00007f2bc82e4ef4 in mongo::repl::_logOpsInner (opCtx=0x7f2ba77e8e20, nss=..., records=0x7f2b91907530,
          timestamps=std::vector of length 1, capacity 1 = {...}, oplogCollection=..., finalOpTime=..., wallTime=...,
          isAbortIndexBuild=false) at src/mongo/db/repl/oplog.cpp:356
      #9  0x00007f2bc82e6adf in mongo::repl::logInsertOps(mongo::OperationContext*, mongo::repl::MutableOplogEntry*, __gnu_cxx::__normal_iterator<mongo::InsertStatement const*, std::vector<mongo::InsertStatement, std::allocator<mongo::InsertStatement> > >, __gnu_cxx::__normal_iterator<mongo::InsertStatement const*, std::vector<mongo::InsertStatement, std::allocator<mongo::InsertStatement> > >, std::function<boost::optional<mongo::ShardId> (mongo::BSONObj const&)>) (opCtx=0x7f2ba77e8e20, oplogEntryTemplate=0x7f2b91907fb8, begin=
          {stmtIds = std::vector of length 1, capacity 1 = {-1}, oplogSlot = {static kTermFieldName = {_data = 0x7f2bca1c0fa0 "t", _size = 1}, static kTimestampFieldName = {_data = 0x7f2bcac4cdb7 "ts", _size = 2}, static kUninitializedTerm = -1, static kInitialTerm = 0, _timestamp = {static kAllowUnstableCheckpointsSentinel = {static kAllowUnstableCheckpointsSentinel = <same as static member of an already seen type>, i = 1, secs = 0}, i = 1, secs = 1626292826}, _term = 1}, doc = owned BSONObj 73 bytes @ 0x7f2b9219c9cb = {[_id] = {"$oid": "60ef4259818941fd74c14e29"}, [a] = {"b": {"c": {"d": {"e": {"f": 1.0}}}}}}}, end=
          {stmtIds = std::vector of length 933982125, capacity -904252160475958426 = {<error reading variable>,
          getDestinedRecipientFn=...) at src/mongo/db/repl/oplog.cpp:560
      #10 0x00007f2bd35ae754 in mongo::OpObserverImpl::onInserts (this=0x7f2baeafeba0, opCtx=0x7f2ba77e8e20, nss=..., uuid=..., first=
          {stmtIds = std::vector of length 1, capacity 1 = {-1}, oplogSlot = {static kTermFieldName = {_data = 0x7f2bca1c0fa0 "t", _size = 1}, static kTimestampFieldName = {_data = 0x7f2bcac4cdb7 "ts", _size = 2}, static kUninitializedTerm = -1, static kInitialTerm = 0, _timestamp = {static kAllowUnstableCheckpointsSentinel = {static kAllowUnstableCheckpointsSentinel = <same as static member of an already seen type>, i = 1, secs = 0}, i = 1, secs = 1626292826}, _term = 1}, doc = owned BSONObj 73 bytes @ 0x7f2b9219c9cb = {[_id] = {"$oid": "60ef4259818941fd74c14e29"}, [a] = {"b": {"c": {"d": {"e": {"f": 1.0}}}}}}}, last=
          {stmtIds = std::vector of length 933982125, capacity -904252160475958426 = {<error reading variable>, fromMigrate=false)
          at src/mongo/db/op_observer_impl.cpp:517
      #11 0x00007f2bd921be7c in mongo::OpObserverRegistry::onInserts (this=0x7f2baeb0b520, opCtx=0x7f2ba77e8e20, nss=..., uuid=..., begin=
          {stmtIds = std::vector of length 1, capacity 1 = {-1}, oplogSlot = {static kTermFieldName = {_data = 0x7f2bca1c0fa0 "t", _size = 1}, static kTimestampFieldName = {_data = 0x7f2bcac4cdb7 "ts", _size = 2}, static kUninitializedTerm = -1, static kInitialTerm = 0, _timestamp = {static kAllowUnstableCheckpointsSentinel = {static kAllowUnstableCheckpointsSentinel = <same as static member of an already seen type>, i = 1, secs = 0}, i = 1, secs = 1626292826}, _term = 1}, doc = owned BSONObj 73 bytes @ 0x7f2b9219c9cb = {[_id] = {"$oid": "60ef4259818941fd74c14e29"}, [a] = {"b": {"c": {"d": {"e": {"f": 1.0}}}}}}}, end=
          {stmtIds = std::vector of length 933982125, capacity -904252160475958426 = {<error reading variable>, fromMigrate=false)
          at src/mongo/db/op_observer_registry.h:124
      #12 0x00007f2bcb252d23 in mongo::CollectionImpl::_insertDocuments (this=0x7f2b9fd8e2b0, opCtx=0x7f2ba77e8e20, begin=
          {stmtIds = std::vector of length 1, capacity 1 = {-1}, oplogSlot = {static kTermFieldName = {_data = 0x7f2bca1c0fa0 "t", _size = 1}, static kTimestampFieldName = {_data = 0x7f2bcac4cdb7 "ts", _size = 2}, static kUninitializedTerm = -1, static kInitialTerm = 0, _timestamp = {static kAllowUnstableCheckpointsSentinel = {static kAllowUnstableCheckpointsSentinel = <same as static member of an already seen type>, i = 1, secs = 0}, i = 1, secs = 1626292826}, _term = 1}, doc = owned BSONObj 73 bytes @ 0x7f2b9219c9cb = {[_id] = {"$oid": "60ef4259818941fd74c14e29"}, [a] = {"b": {"c": {"d": {"e": {"f": 1.0}}}}}}}, end=
          {stmtIds = std::vector of length 933982125, capacity -904252160475958426 = {<error reading variable>, opDebug=0x7f2ba71afa68,
          fromMigrate=false) at src/mongo/db/catalog/collection_impl.cpp:826
      #13 0x00007f2bcb251d7d in mongo::CollectionImpl::insertDocuments (this=0x7f2b9fd8e2b0, opCtx=0x7f2ba77e8e20, begin=
          {stmtIds = std::vector of length 1, capacity 1 = {-1}, oplogSlot = {static kTermFieldName = {_data = 0x7f2bca1c0fa0 "t", _size = 1}, static kTimestampFieldName = {_data = 0x7f2bcac4cdb7 "ts", _size = 2}, static kUninitializedTerm = -1, static kInitialTerm = 0, _timestamp = {static kAllowUnstableCheckpointsSentinel = {static kAllowUnstableCheckpointsSentinel = <same as static member of an already seen type>, i = 1, secs = 0}, i = 1, secs = 1626292826}, _term = 1}, doc = owned BSONObj 73 bytes @ 0x7f2b9219c9cb = {[_id] = {"$oid": "60ef4259818941fd74c14e29"}, [a] = {"b": {"c": {"d": {"e": {"f": 1.0}}}}}}}, end=
          {stmtIds = std::vector of length 933982125, capacity -904252160475958426 = {<error reading variable>, opDebug=0x7f2ba71afa68,
          fromMigrate=false) at src/mongo/db/catalog/collection_impl.cpp:640
      #14 0x00007f2bcdf20d17 in mongo::write_ops_exec::(anonymous namespace)::insertDocuments (opCtx=0x7f2ba77e8e20, collection=...,
          begin=
          {stmtIds = std::vector of length 1, capacity 1 = {-1}, oplogSlot = {static kTermFieldName = {_data = 0x7f2bca1c0fa0 "t", _size = 1}, static kTimestampFieldName = {_data = 0x7f2bcac4cdb7 "ts", _size = 2}, static kUninitializedTerm = -1, static kInitialTerm = 0, _timestamp = {static kAllowUnstableCheckpointsSentinel = {static kAllowUnstableCheckpointsSentinel = <same as static member of an already seen type>, i = 1, secs = 0}, i = 1, secs = 1626292826}, _term = 1}, doc = owned BSONObj 73 bytes @ 0x7f2b9219c9cb = {[_id] = {"$oid": "60ef4259818941fd74c14e29"}, [a] = {"b": {"c": {"d": {"e": {"f": 1.0}}}}}}}, end=
          {stmtIds = std::vector of length 933982125, capacity -904252160475958426 = {<error reading variable>, fromMigrate=false)
          at src/mongo/db/ops/write_ops_exec.cpp:359
      #15 0x00007f2bcdf22909 in mongo::write_ops_exec::(anonymous namespace)::insertBatchAndHandleErrors(mongo::OperationContext*, mongo::write_ops::InsertCommandRequest const&, std::vector<mongo::InsertStatement, std::allocator<mongo::InsertStatement> >&, mongo::write_ops_exec::(anonymous namespace)::LastOpFixer*, mongo::write_ops_exec::WriteResult*, mongo::OperationSource)::$_4::operator()() const (
          this=0x7f2b91908f88) at src/mongo/db/ops/write_ops_exec.cpp:520
      #16 0x00007f2bcdf20ee8 in mongo::writeConflictRetry<mongo::write_ops_exec::(anonymous namespace)::insertBatchAndHandleErrors(mongo::OperationContext*, mongo::write_ops::InsertCommandRequest const&, std::vector<mongo::InsertStatement, std::allocator<mongo::InsertStatement> >&, mongo::write_ops_exec::(anonymous namespace)::LastOpFixer*, mongo::write_ops_exec::WriteResult*, mongo::OperationSource)::$_4>(mongo::OperationContext*, mongo::StringData, mongo::StringData, mongo::write_ops_exec::(anonymous namespace)::insertBatchAndHandleErrors(mongo::OperationContext*, mongo::write_ops::InsertCommandRequest const&, std::vector<mongo::InsertStatement, std::allocator<mongo::InsertStatement> >&, mongo::write_ops_exec::(anonymous namespace)::LastOpFixer*, mongo::write_ops_exec::WriteResult*, mongo::OperationSource)::$_4&&) (opCtx=0x7f2ba77e8e20, opStr="insert", ns="test.c", f=...)
          at src/mongo/db/concurrency/write_conflict_exception.h:98
      #17 0x00007f2bcdf19136 in mongo::write_ops_exec::(anonymous namespace)::insertBatchAndHandleErrors (opCtx=0x7f2ba77e8e20,
          wholeOp=..., batch=std::vector of length 1, capacity 1 = {...}, lastOpFixer=0x7f2b91909530, out=0x7f2b919097a8,
          source=mongo::kStandard) at src/mongo/db/ops/write_ops_exec.cpp:512
      #18 0x00007f2bcdf18155 in mongo::write_ops_exec::performInserts (opCtx=0x7f2ba77e8e20, wholeOp=...,
          source=@0x7f2b919097a4: mongo::kStandard) at src/mongo/db/ops/write_ops_exec.cpp:682
      #19 0x00007f2bba484a88 in mongo::(anonymous namespace)::CmdInsert::Invocation::typedRun (this=0x7f2b92110720, opCtx=0x7f2ba77e8e20)
          at src/mongo/db/commands/write_commands.cpp:662
      ...
      

            Assignee:
            gregory.noma@mongodb.com Gregory Noma
            Reporter:
            gregory.noma@mongodb.com Gregory Noma
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: