summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-05-12 12:16:10 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-15 13:40:50 +0000
commit0e88ea0eccab014918f014b5c858189b1eede4fb (patch)
tree866e2ae57671b6dadb70535f8fa8e603ca49a7f1
parentb3bb8e9c099b0a8cecdf5d76f9109af927eff0d3 (diff)
downloadmongo-0e88ea0eccab014918f014b5c858189b1eede4fb.tar.gz
SERVER-48141 Fix crash in radix store merge3 when merging trees sharing branches not in base
-rw-r--r--src/mongo/db/storage/biggie/store.h4
-rw-r--r--src/mongo/db/storage/biggie/store_test.cpp16
2 files changed, 19 insertions, 1 deletions
diff --git a/src/mongo/db/storage/biggie/store.h b/src/mongo/db/storage/biggie/store.h
index 6798c7aafb0..72e6a639d6f 100644
--- a/src/mongo/db/storage/biggie/store.h
+++ b/src/mongo/db/storage/biggie/store.h
@@ -936,7 +936,9 @@ private:
}
depth++;
- if (depth == key.size()) {
+ // Return node if entire trieKey matches.
+ if (depth == key.size() &&
+ (key.size() - initialDepthOffset) == _root->_trieKey.size()) {
return _root.get();
}
}
diff --git a/src/mongo/db/storage/biggie/store_test.cpp b/src/mongo/db/storage/biggie/store_test.cpp
index 79fbc3de6ed..849df0d4c26 100644
--- a/src/mongo/db/storage/biggie/store_test.cpp
+++ b/src/mongo/db/storage/biggie/store_test.cpp
@@ -1597,6 +1597,22 @@ TEST_F(RadixStoreTest, MergeOnlyDataDifferenceInBranch) {
ASSERT_TRUE(thisStore == expected);
}
+TEST_F(RadixStoreTest, MergeSharedSubKey) {
+ otherStore = baseStore;
+
+ otherStore.insert({"aaa", "a"});
+ otherStore.insert({"aaab", "b"});
+
+ thisStore = baseStore;
+ thisStore.insert({"aaaa", "a"});
+ thisStore.merge3(baseStore, otherStore);
+
+ expected.insert({"aaa", "a"});
+ expected.insert({"aaaa", "a"});
+ expected.insert({"aaab", "b"});
+ ASSERT_TRUE(thisStore == expected);
+}
+
TEST_F(RadixStoreTest, MergeConflictingModifications) {
value_type value1 = std::make_pair("foo", "1");
value_type value2 = std::make_pair("foo", "2");