summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/capped_resize.js8
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp4
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()) {