summaryrefslogtreecommitdiff
path: root/src/mongo/base
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/base
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/base')
-rw-r--r--src/mongo/base/dependency_graph.cpp1
-rw-r--r--src/mongo/base/error_codes.tpl.cpp2
-rw-r--r--src/mongo/base/error_codes.yml28
-rw-r--r--src/mongo/base/murmurhash3_test.cpp142
-rw-r--r--src/mongo/base/secure_allocator.cpp15
-rw-r--r--src/mongo/base/simple_string_data_comparator.cpp26
6 files changed, 92 insertions, 122 deletions
diff --git a/src/mongo/base/dependency_graph.cpp b/src/mongo/base/dependency_graph.cpp
index faa8b8cdae3..8d9107b5a10 100644
--- a/src/mongo/base/dependency_graph.cpp
+++ b/src/mongo/base/dependency_graph.cpp
@@ -29,7 +29,6 @@
#include "mongo/base/dependency_graph.h"
-#include "mongo/util/stacktrace.h"
#include <algorithm>
#include <fmt/format.h>
#include <fmt/ranges.h>
diff --git a/src/mongo/base/error_codes.tpl.cpp b/src/mongo/base/error_codes.tpl.cpp
index bd2071c2627..a51621590c5 100644
--- a/src/mongo/base/error_codes.tpl.cpp
+++ b/src/mongo/base/error_codes.tpl.cpp
@@ -32,8 +32,6 @@
#include "mongo/base/error_codes.h"
#include "mongo/base/static_assert.h"
-#include "mongo/db/concurrency/temporarily_unavailable_exception.h"
-#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/str.h"
diff --git a/src/mongo/base/error_codes.yml b/src/mongo/base/error_codes.yml
index 6b43f74536f..0b3150042bd 100644
--- a/src/mongo/base/error_codes.yml
+++ b/src/mongo/base/error_codes.yml
@@ -174,7 +174,7 @@ error_codes:
#- {code: 131,name: RLPInitializationFailed} # Removed in 4.2
- {code: 132,name: OBSOLETE_ConfigServersInconsistent}
- {code: 133,name: FailedToSatisfyReadPreference}
- - {code: 134,name: ReadConcernMajorityNotAvailableYet, categories: [RetriableError]}
+ - {code: 134,name: ReadConcernMajorityNotAvailableYet}
- {code: 135,name: StaleTerm}
- {code: 136,name: CappedPositionLost}
- {code: 137,name: IncompatibleShardingConfigVersion}
@@ -301,9 +301,9 @@ error_codes:
- {code: 250,name: StaleChunkHistory,categories: [SnapshotError]}
- {code: 251,name: NoSuchTransaction,categories: [VoteAbortError]}
- {code: 252,name: ReentrancyNotAllowed}
- # - {code: 253,name: FreeMonHttpInFlight} # Removed in 7.1
- # - {code: 254,name: FreeMonHttpTemporaryFailure} # Removed in 7.1
- # - {code: 255,name: FreeMonHttpPermanentFailure} # Removed in 7.1
+ - {code: 253,name: FreeMonHttpInFlight}
+ - {code: 254,name: FreeMonHttpTemporaryFailure}
+ - {code: 255,name: FreeMonHttpPermanentFailure}
- {code: 256,name: TransactionCommitted}
- {code: 257,name: TransactionTooLarge}
- {code: 258,name: UnknownFeatureCompatibilityVersion}
@@ -428,6 +428,9 @@ error_codes:
- {code: 341, name: ReshardCollectionAborted}
- {code: 342, name: ReshardingCriticalSectionTimeout}
+ # ShardCannotRefreshDueToLocksHeld will be retried by the shards. Note that it is not under the
+ # NeedRetargettingError, meaning MongoS will pass it through to the client, because there is no
+ # case where it would be possible for MongoS to retry where MongoD couldn't.
- {code: 343, name: ShardCannotRefreshDueToLocksHeld,
extra: ShardCannotRefreshDueToLocksHeldInfo}
@@ -488,23 +491,6 @@ error_codes:
- {code: 374, name: TransactionAPIMustRetryTransaction, categories: [InternalOnly]}
- {code: 375, name: TransactionAPIMustRetryCommit, categories: [InternalOnly]}
- {code: 377, name: FLEMaxTagLimitExceeded }
- - {code: 378, name: NonConformantBSON, categories: [ValidationError]}
-
- - {code: 379, name: DatabaseMetadataRefreshCanceled, categories: [InternalOnly]}
-
- - {code: 387, name: EncounteredFLEPayloadWhileApplyingHmac}
-
- - {code: 388, name: TransactionTooLargeForCache}
-
- # This error code is not generated internally in mongod/s servers, but must be parsed and
- # reserve an error code. It can be returned by a remote search index management server.
- - {code: 396, name: IndexInformationTooLarge}
-
- - {code: 398, name: StreamTerminated, categories: [CloseConnectionError]}
-
- - {code: 384, name: ConnectionError, categories: [NetworkError,RetriableError,InternalOnly]}
-
- - {code: 408, name: CannotInsertTimeseriesBucketsWithMixedSchema}
# Error codes 4000-8999 are reserved.
diff --git a/src/mongo/base/murmurhash3_test.cpp b/src/mongo/base/murmurhash3_test.cpp
index fd780ce6217..a2f4219b856 100644
--- a/src/mongo/base/murmurhash3_test.cpp
+++ b/src/mongo/base/murmurhash3_test.cpp
@@ -30,32 +30,35 @@
#include <array>
#include <string>
-#include "mongo/base/data_type_endian.h"
-#include "mongo/base/data_view.h"
-#include "mongo/unittest/unittest.h"
-#include "mongo/util/murmur3.h"
+#include <third_party/murmurhash3/MurmurHash3.h>
-#define TEST_STRING32(str, seed, expected) \
- ASSERT_EQUALS(murmur3<sizeof(uint32_t)>(StringData{str}, seed), expected)
+#include "mongo/unittest/unittest.h"
-#define TEST_STRING64(str, seed, expected) \
- ASSERT_EQUALS(murmur3<sizeof(uint64_t)>(StringData{str}, seed), expected)
+#include "mongo/base/data_type_endian.h"
+#include "mongo/base/data_view.h"
-#define TEST_STRING128(str, seed, a, b) \
- do { \
- auto pair = compute128(StringData{str}, seed); \
- ASSERT_EQUALS(pair.first, a); \
- ASSERT_EQUALS(pair.second, b); \
+#define TEST_STRING32(str, seed, expected) ASSERT_EQUALS(compute32(str, seed), expected)
+#define TEST_STRING64(str, seed, a, b) \
+ do { \
+ auto pair = compute128(str, seed); \
+ ASSERT_EQUALS(pair.first, a); \
+ ASSERT_EQUALS(pair.second, b); \
} while (0)
namespace mongo {
namespace {
+uint32_t compute32(StringData input, uint32_t seed) {
+ char hash[4];
+ MurmurHash3_x86_32(input.rawData(), input.size(), seed, &hash);
+ return ConstDataView(hash).read<LittleEndian<uint32_t>>();
+}
+
std::pair<uint64_t, uint64_t> compute128(StringData input, uint32_t seed) {
- std::array<char, 16> hash;
- murmur3(input, seed, hash);
- return {ConstDataView(hash.data()).read<LittleEndian<uint64_t>>(),
- ConstDataView(hash.data()).read<LittleEndian<uint64_t>>(8)};
+ char hash[16];
+ MurmurHash3_x64_128(input.rawData(), input.size(), seed, &hash);
+ return {ConstDataView(hash).read<LittleEndian<uint64_t>>(),
+ ConstDataView(hash).read<LittleEndian<uint64_t>>(8)};
}
TEST(MurmurHash3, TestVectors32) {
@@ -89,78 +92,51 @@ TEST(MurmurHash3, TestVectors32) {
}
-TEST(MurmurHash3, TestVectors128) {
- TEST_STRING128("", 0, 0ULL, 0ULL);
-
- TEST_STRING128("", 1ULL, 5048724184180415669ULL, 5864299874987029891ULL);
- // Make sure seed value is handled unsigned.
- TEST_STRING128("", 0xffffffffULL, 7706185961851046380ULL, 9616347466054386795ULL);
- // Make sure we handle embedded nulls.
- TEST_STRING128("\0\0\0\0"_sd, 0ULL, 14961230494313510588ULL, 6383328099726337777ULL);
-
- // One full chunk.
- TEST_STRING128("aaaa", 0x9747b28cULL, 13033599803469372400ULL, 11949150323828610719ULL);
- // Three characters.
- TEST_STRING128("aaa", 0x9747b28cULL, 10278871841506805355ULL, 17952965428487426844ULL);
- // Two characters.
- TEST_STRING128("aa", 0x9747b28cULL, 1343929393636293407ULL, 16804672932933964801ULL);
- // One character.
- TEST_STRING128("a", 0x9747b28cULL, 6694838689256856093ULL, 11415968713816993796ULL);
-
- // Endian order within the chunks
- TEST_STRING128("abcd", 0x9747b28cULL, 5310993687375067025ULL, 9979528070057666491ULL);
- TEST_STRING128("abc", 0x9747b28cULL, 3982135406228655836ULL, 14835035517329147071ULL);
- TEST_STRING128("ab", 0x9747b28cULL, 9526501539032868875ULL, 9131386788375312171ULL);
- TEST_STRING128("a", 0x9747b28cULL, 6694838689256856093ULL, 11415968713816993796ULL);
-
- TEST_STRING128(
- "Hello, world!", 0x9747b28cULL, 17132966038248896814ULL, 17896881015324243642ULL);
-
- // Make sure to handle UTF-8 high characters. A bcrypt implementation messed this up. Here we
- // use U+03C0: Greek Small Letter Pi.
- TEST_STRING128("ππππππππ", 0x9747b28cULL, 10874605236735318559ULL, 17921841414653337979ULL);
-
- // String of 256 characters. Make sure you don't store string lengths in a char, and overflow at
- // 255 bytes (as OpenBSD's canonical BCrypt implementation did).
- TEST_STRING128(
- std::string(256, 'a'), 0x9747b28cULL, 557766291455132100ULL, 14184293241195392597ULL);
-}
-
-// Output of the 64-bit version of murmur3() should be the same as the first 8 bytes of the 128-bit
-// version.
TEST(MurmurHash3, TestVectors64) {
- TEST_STRING64("", 0, 0ULL);
-
- TEST_STRING64("", 1ULL, 5048724184180415669ULL);
- // Make sure seed value is handled unsigned.
- TEST_STRING64("", 0xffffffffULL, 7706185961851046380ULL);
- // Make sure we handle embedded nulls.
- TEST_STRING64("\0\0\0\0"_sd, 0ULL, 14961230494313510588ULL);
-
- // One full chunk.
- TEST_STRING64("aaaa", 0x9747b28cULL, 13033599803469372400ULL);
- // Three characters.
- TEST_STRING64("aaa", 0x9747b28cULL, 10278871841506805355ULL);
- // Two characters.
- TEST_STRING64("aa", 0x9747b28cULL, 1343929393636293407ULL);
- // One character.
- TEST_STRING64("a", 0x9747b28cULL, 6694838689256856093ULL);
+ TEST_STRING64("", 0, 0ULL, 0ULL);
+
+ TEST_STRING64("", 1ULL, 5048724184180415669ULL, 5864299874987029891ULL);
+ TEST_STRING64("",
+ 0xffffffffULL,
+ 7706185961851046380ULL,
+ 9616347466054386795ULL); // make sure seed value is handled unsigned
+ TEST_STRING64("\0\0\0\0"_sd,
+ 0ULL,
+ 14961230494313510588ULL,
+ 6383328099726337777ULL); // make sure we handle embedded nulls
+
+
+ TEST_STRING64(
+ "aaaa", 0x9747b28cULL, 13033599803469372400ULL, 11949150323828610719ULL); // one full chunk
+ TEST_STRING64("aaa",
+ 0x9747b28cULL,
+ 10278871841506805355ULL,
+ 17952965428487426844ULL); // three characters
+ TEST_STRING64(
+ "aa", 0x9747b28cULL, 1343929393636293407ULL, 16804672932933964801ULL); // two characters
+ TEST_STRING64(
+ "a", 0x9747b28cULL, 6694838689256856093ULL, 11415968713816993796ULL); // one character
// Endian order within the chunks
- TEST_STRING64("abcd", 0x9747b28cULL, 5310993687375067025ULL);
- TEST_STRING64("abc", 0x9747b28cULL, 3982135406228655836ULL);
- TEST_STRING64("ab", 0x9747b28cULL, 9526501539032868875ULL);
- TEST_STRING64("a", 0x9747b28cULL, 6694838689256856093ULL);
+ TEST_STRING64(
+ "abcd", 0x9747b28cULL, 5310993687375067025ULL, 9979528070057666491ULL); // one full chunk
+ TEST_STRING64("abc", 0x9747b28cULL, 3982135406228655836ULL, 14835035517329147071ULL);
+ TEST_STRING64("ab", 0x9747b28cULL, 9526501539032868875ULL, 9131386788375312171ULL);
+ TEST_STRING64("a", 0x9747b28cULL, 6694838689256856093ULL, 11415968713816993796ULL);
- TEST_STRING64("Hello, world!", 0x9747b28cULL, 17132966038248896814ULL);
+ TEST_STRING64("Hello, world!", 0x9747b28cULL, 17132966038248896814ULL, 17896881015324243642ULL);
- // Make sure to handle UTF-8 high characters. A bcrypt implementation messed this up. Here we
- // use U+03C0: Greek Small Letter Pi.
- TEST_STRING64("ππππππππ", 0x9747b28cULL, 10874605236735318559ULL);
+ // Make sure you handle UTF-8 high characters. A bcrypt implementation messed this up
+ TEST_STRING64("ππππππππ",
+ 0x9747b28cULL,
+ 10874605236735318559ULL,
+ 17921841414653337979ULL); // U+03C0: Greek Small Letter Pi
- // String of 256 characters. Make sure you don't store string lengths in a char, and overflow at
- // 255 bytes (as OpenBSD's canonical BCrypt implementation did).
- TEST_STRING64(std::string(256, 'a'), 0x9747b28cULL, 557766291455132100ULL);
+ // String of 256 characters.
+ // Make sure you don't store string lengths in a char, and overflow at 255 bytes (as OpenBSD's
+ // canonical BCrypt implementation did)
+ TEST_STRING64(
+ std::string(256, 'a'), 0x9747b28cULL, 557766291455132100ULL, 14184293241195392597ULL);
}
} // namespace
diff --git a/src/mongo/base/secure_allocator.cpp b/src/mongo/base/secure_allocator.cpp
index 0062005ae85..47837cb5c7d 100644
--- a/src/mongo/base/secure_allocator.cpp
+++ b/src/mongo/base/secure_allocator.cpp
@@ -37,7 +37,6 @@
#include <memory>
#ifdef _WIN32
-#include <psapi.h>
#include <windows.h>
#else
#include <sys/mman.h>
@@ -146,19 +145,7 @@ void growWorkingSize(std::size_t bytes) {
// Since allocation request is aligned to page size, we can just add it to the current working
// set size.
- // Note: The default dwMaximumWorkingSetSize for a process is 345 pages on a system with 4k
- // pages (i.e x64). This is not the same as the current working set of the process. It usually
- // far lower. The min value is ignored by Windows until the machine is starved for memory or
- // MongoDB wants to lock pages. The max value is treated as a target working set goal for a
- // process that Windows should meet. This means that if MongoDB sets the number too low, Windows
- // will flush the process out to the page file which will cause the process to freeze while this
- // occurs. MongoDB will set the dwMaximumWorkingSetSize to 90% of physical RAM. On high memory
- // systems (> 128GB0), this may be too conservative so use 5GB as a threshold.
- uint64_t physicalRamSize = ProcessInfo::getMemSizeMB() * 1024ULL * 1024ULL;
-
- maxWorkingSetSize = physicalRamSize -
- std::min(0.10 * physicalRamSize,
- static_cast<double>(5ULL * 1024ULL * 1024ULL * 1024ULL) /* 5 GB */);
+ maxWorkingSetSize = std::max(minWorkingSetSize + bytes + minGap, maxWorkingSetSize);
// Increase the working set size minimum to the new lower bound.
if (!SetProcessWorkingSetSizeEx(GetCurrentProcess(),
diff --git a/src/mongo/base/simple_string_data_comparator.cpp b/src/mongo/base/simple_string_data_comparator.cpp
index c03fddf4316..eaeb67ac829 100644
--- a/src/mongo/base/simple_string_data_comparator.cpp
+++ b/src/mongo/base/simple_string_data_comparator.cpp
@@ -31,10 +31,34 @@
#include "mongo/base/simple_string_data_comparator.h"
-#include "mongo/util/murmur3.h"
+#include <third_party/murmurhash3/MurmurHash3.h>
+
+#include "mongo/base/data_type_endian.h"
+#include "mongo/base/data_view.h"
namespace mongo {
+namespace {
+
+template <int SizeofSizeT>
+size_t murmur3(StringData str, size_t seed);
+
+template <>
+size_t murmur3<4>(StringData str, size_t seed) {
+ char hash[4];
+ MurmurHash3_x86_32(str.rawData(), str.size(), seed, &hash);
+ return ConstDataView(hash).read<LittleEndian<std::uint32_t>>();
+}
+
+template <>
+size_t murmur3<8>(StringData str, size_t seed) {
+ char hash[16];
+ MurmurHash3_x64_128(str.rawData(), str.size(), seed, hash);
+ return static_cast<size_t>(ConstDataView(hash).read<LittleEndian<std::uint64_t>>());
+}
+
+} // namespace
+
const SimpleStringDataComparator SimpleStringDataComparator::kInstance{};
int SimpleStringDataComparator::compare(StringData left, StringData right) const {