-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Triage
Dear mongo dev,
With mongodb 5.0, if i have a shard collection with a key {"serial":1}, and a datetime TTL.
i can get a chunk with serial 1, another chunk with serial 2. but one day i can have the chunk with serial 1 empty.
How i can remove the unnecessary chunk, how can i know this chunk is empty ?
with mongodb 5.0 scripts like :
var ns = "ns.col"; var key = db.getSiblingDB("config").collections.findOne({_id: ns}).key; db.getSiblingDB("config").chunks.find({ns : ns}).forEach(function(chunk) { var ds = db.getSiblingDB(chunk.ns.split(".")[0]).runCommand({datasize:chunk.ns, keyPattern:key, min:chunk.min, max:chunk.max, estimate:true}); var size = ds.size/(1024*1024); printjson({chunk:chunk._id, datasize_MB: size}); });
doesn't work anymore because in config.chunk doesn't have NS now.
Moreover i think mongodb should remove empty chunk automatically.