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

using timestamp in document replacement in stitch support library apply update

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Labels:
      None

      Description

      Stack trace:

          at /opt/mongodbtoolchain/revisions/9b224ef3e13ae2094ba3c865966ac238660d9552/stow/gcc-v3.fo3/include/c++/8.2.0/x86_64-mongodb-linux/bits/gthr-default.h:748
      #15 lock (this=0x0) at /opt/mongodbtoolchain/revisions/9b224ef3e13ae2094ba3c865966ac238660d9552/stow/gcc-v3.fo3/include/c++/8.2.0/bits/std_mutex.h:103
      #16 lock_guard (__m=..., this=<synthetic pointer>) at /opt/mongodbtoolchain/revisions/9b224ef3e13ae2094ba3c865966ac238660d9552/stow/gcc-v3.fo3/include/c++/8.2.0/bits/std_mutex.h:162
      #17 mongo::LogicalClock::reserveTicks(unsigned long) () at src/mongo/db/logical_clock.cpp:102
      Backtrace stopped: previous frame identical to this frame (corrupt stack?)
      

      Relevant code that seems to crash is here:

      ObjectReplaceExecutor::ObjectReplaceExecutor(BSONObj replacement)
          : _replacementDoc(replacement.getOwned()), _containsId(false) {
          // Replace all zero-valued timestamps with the current time and check for the existence of _id.
          for (auto&& elem : _replacementDoc) {
              // Do not change the _id field.
              if (elem.fieldNameStringData() == kIdFieldName) {
                  _containsId = true;
                  continue;
              }
              if (elem.type() == BSONType::bsonTimestamp) {
                  auto timestampView = DataView(const_cast<char*>(elem.value()));
                  // We don't need to do an endian-safe read here, because 0 is 0 either way.
                  unsigned long long timestamp = timestampView.read<unsigned long long>();
                  if (timestamp == 0) {
                      ServiceContext* service = getGlobalServiceContext();
                      auto ts = LogicalClock::get(service)->reserveTicks(1).asTimestamp();
                      timestampView.write(tagLittleEndian(ts.asULL()));
                  }
              }
          }
      }
      
      

      Seems like LogicalClock::get(service) is returning nullptr when it enters the codepath via the stitch support lib.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: