[SERVER-12794] create command updates ns "size" option to actual min size Created: 19/Feb/14  Updated: 06/Dec/22  Resolved: 01/Apr/19

Status: Closed
Project: Core Server
Component/s: Diagnostics, Storage
Affects Version/s: 2.5.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Bernie Hackett Assignee: Backlog - Storage Execution Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Operating System: ALL
Participants:

 Description   

This may be intentional, based on some commits in SERVER-8412, especially:

https://github.com/mongodb/mongo/commit/6718e33f5ecd0de4a8550afaf789c2fc416b6eee

MongoDB 2.4.9:

repl0:PRIMARY> db.createCollection('test', {capped: true, size: 1000})
{ "ok" : 1 }
repl0:PRIMARY> db.system.namespaces.findOne({name: 'test.test'}).options
{ "create" : "test", "capped" : true, "size" : 1000 }

MongoDB 2.5.6-pre-

repl0:PRIMARY> db.test.drop()
true
repl0:PRIMARY> db.createCollection('test', {capped: true, size: 1000})
{ "ok" : 1 }
repl0:PRIMARY> db.system.namespaces.findOne({name: 'test.test'}).options
{ "capped" : true, "size" : 4096 }
repl0:PRIMARY> 
repl0:PRIMARY> db.test.drop()
true
repl0:PRIMARY> db.createCollection('test', {capped: true, size: 1024})
{ "ok" : 1 }
repl0:PRIMARY> db.system.namespaces.findOne({name: 'test.test'}).options
{ "capped" : true, "size" : 4096 }
repl0:PRIMARY>
repl0:PRIMARY> db.test.drop()
true
repl0:PRIMARY> db.createCollection('test', {capped: true, size: 8099})
{ "ok" : 1 }
repl0:PRIMARY> db.system.namespaces.findOne({name: 'test.test'}).options
{ "capped" : true, "size" : 8192 }
repl0:PRIMARY> db.adminCommand('buildInfo')
{
	"version" : "2.5.6-pre-",
	"gitVersion" : "9b93e7e43e279e2458d8e624750b561875611c18",
	"OpenSSLVersion" : "OpenSSL 1.0.1f 6 Jan 2014",
	"sysInfo" : "Linux behackett-dt 3.10.25-gentoo #1 SMP PREEMPT Mon Jan 13 12:21:14 PST 2014 x86_64 BOOST_LIB_VERSION=1_49",
	"loaderFlags" : "-fPIC -pthread -Wl,-z,now -rdynamic",
	"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp",
	"allocator" : "tcmalloc",
	"versionArray" : [
		2,
		5,
		6,
		-100
	],
	"javascriptEngine" : "V8",
	"bits" : 64,
	"debug" : false,
	"maxBsonObjectSize" : 16777216,
	"ok" : 1
}
repl0:PRIMARY>



 Comments   
Comment by Amalia Hawkins [ 18/Mar/14 ]

Our current behavior is to round the given capped collection size up to the nearest multiple of 256, then check if it's smaller than the minimum size (4096) – if it is smaller, then we use 4096 as the size instead.

Comment by Githook User [ 21/Feb/14 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: Fix createCollection tests for 2.5.x

Use 4096 for capped collection size instead of 100, since server rounds up to the nearest extent anyway. As of https://jira.mongodb.org/browse/SERVER-12794, the actual storage size is reported, so we can use and expect 4096.

Additionally, use dump_these_keys() to print collection options, so we don't need to worry about extra options or their order.
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/d3e93ad24dc77bb6d13b30351e285b0cef7c0ac9

Comment by Eliot Horowitz (Inactive) [ 20/Feb/14 ]

test that fails on 2.4 but passes on 2.6

diff --git a/jstests/capped_empty.js b/jstests/capped_empty.js
index 5b0fb6b..30f78bf 100644
--- a/jstests/capped_empty.js
+++ b/jstests/capped_empty.js
@@ -4,6 +4,11 @@ t.drop();
 
 db.createCollection( t.getName() , { capped : true , size : 100 } )
 
+catalog = db.system.namespaces.findOne( { name : t.getFullName() } );
+stats = t.stats();
+assert.eq( catalog.options.size, stats.storageSize,
+           "size mismatch " + tojson( catalog ) + " " + tojson( stats ) );
+
 t.insert( { x : 1 } );
 t.insert( { x : 2 } );
 t.insert( { x : 3 } );

Comment by Daniel Pasette (Inactive) [ 19/Feb/14 ]

This has no impact on correctness. It is cosmetic, but leaving in rc1 to document.

Generated at Thu Feb 08 03:29:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.