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

Side table writes insert more than just the keystring

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.7, 5.0.0-rc4, 5.1.0-rc0
    • Affects Version/s: 4.4.0, 5.0.0-rc0
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v5.0, v4.4
    • Hide
      diff --git a/src/mongo/db/index/index_build_interceptor.cpp b/src/mongo/db/index/index_build_interceptor.cpp
      index 2e79179df2..c7656c061f 100644
      --- a/src/mongo/db/index/index_build_interceptor.cpp
      +++ b/src/mongo/db/index/index_build_interceptor.cpp
      @@ -469,6 +469,9 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx,
               builder.reset();
               keyString.serialize(builder);
               BSONBinData binData(builder.buf(), builder.getSize(), BinDataGeneral);
      +        logd("DBG. SideWrite. KeyString Size: {} BinData Size: {}",
      +             keyString.getSize(),
      +             binData.length);
               toInsert.emplace_back(BSON("op" << (op == Op::kInsert ? "i" : "d") << "key" << binData));
           }
       
      
      resmoke run jstests/noPassthrough/hybrid_index_with_updates.js
      ...
      [js_test:hybrid_index_with_updates] d20020| 2021-06-07T09:50:55.731-04:00 I  -        [conn1] DBG. SideWrite. KeyString Size: 6 BinData Size: 512
      
      Show
      diff --git a/src/mongo/db/index/index_build_interceptor.cpp b/src/mongo/db/index/index_build_interceptor.cpp index 2e79179df2..c7656c061f 100644 --- a/src/mongo/db/index/index_build_interceptor.cpp +++ b/src/mongo/db/index/index_build_interceptor.cpp @@ -469,6 +469,9 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx, builder.reset(); keyString.serialize(builder); BSONBinData binData(builder.buf(), builder.getSize(), BinDataGeneral); + logd("DBG. SideWrite. KeyString Size: {} BinData Size: {}", + keyString.getSize(), + binData.length); toInsert.emplace_back(BSON("op" << (op == Op::kInsert ? "i" : "d") << "key" << binData)); } resmoke run jstests/noPassthrough/hybrid_index_with_updates.js ... [js_test:hybrid_index_with_updates] d20020| 2021-06-07T09:50:55.731-04:00 I - [conn1] DBG. SideWrite. KeyString Size: 6 BinData Size: 512
    • Execution Team 2021-06-28

      Writes to the side table re-use a BufBuilder to write keystrings to the hybrid index build side-table.

      It seems the BinData value in the side-write gets the a length derived from the capacity of the builders buffer instead of the length. This results in (at best) wasteful resource usage (for example writing out 512 bytes for 5 byte keystrings) and (at worst) a correctness problem due to undefined behavior.

            Assignee:
            louis.williams@mongodb.com Louis Williams
            Reporter:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: