diff options
author | Benety Goh <benety@mongodb.com> | 2022-06-15 06:39:15 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-15 11:05:46 +0000 |
commit | 82ddea1581794f10126169c357b4fbdd414178fc (patch) | |
tree | 8c65dbd2c0a56939548c0955de1e8db0769c141b | |
parent | 51e661694db82f5751f86a2efdd83c2427c32ed1 (diff) | |
download | mongo-82ddea1581794f10126169c357b4fbdd414178fc.tar.gz |
Revert "SERVER-67036 remove floor for collMod cappedSize option to be consistent with create command"
This reverts commit 51e661694db82f5751f86a2efdd83c2427c32ed1.
-rw-r--r-- | jstests/core/capped_resize.js | 8 | ||||
-rw-r--r-- | src/mongo/db/catalog/coll_mod.cpp | 4 |
2 files changed, 3 insertions, 9 deletions
diff --git a/jstests/core/capped_resize.js b/jstests/core/capped_resize.js index 06baab6b21e..38cc7abd9a0 100644 --- a/jstests/core/capped_resize.js +++ b/jstests/core/capped_resize.js @@ -83,14 +83,6 @@ let verifyLimitUpdate = function(updates) { assert.eq(stats.count, initialDocSize); assert.lte(stats.size, maxSize); - // We used to not allow resizing the size of a capped collection below 4096 bytes. This - // restriction was lifted in SERVER-67036. - // We should see a reduction in collection size and count relative to the previous test case. - verifyLimitUpdate({cappedSize: 256}); - stats = assert.commandWorked(cappedColl.stats()); - assert.lt(stats.count, initialDocSize); - assert.lt(stats.size, maxSize); - // We expect the resizing of a capped collection to fail when maxSize <= 0 and maxSize > // maxSizeCeiling. const negativeSize = -1 * maxSize; diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 8af0ba8efc9..ca5f29ae55e 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -175,11 +175,13 @@ StatusWith<std::pair<ParsedCollModRequest, BSONObj>> parseCollModRequest(Operati } if (auto& cappedSize = cmr.getCappedSize()) { + static constexpr long long minCappedSize = 4096; auto swCappedSize = CollectionOptions::checkAndAdjustCappedSize(*cappedSize); if (!swCappedSize.isOK()) { return swCappedSize.getStatus(); } - parsed.cappedSize = swCappedSize.getValue(); + parsed.cappedSize = + (swCappedSize.getValue() < minCappedSize) ? minCappedSize : swCappedSize.getValue(); oplogEntryBuilder.append(CollMod::kCappedSizeFieldName, *cappedSize); } if (auto& cappedMax = cmr.getCappedMax()) { |