- Sharding >
- Sharded Cluster Administration >
- Clear
jumbo
Flag
Clear jumbo
Flag¶
On this page
If MongoDB cannot split a chunk that exceeds the specified chunk size, MongoDB labels the chunk as jumbo.
If the chunk size no longer exceeds the specified chunk size, MongoDB automatically clears the jumbo
flag
for the chunk when the mongos
rewrites the chunk
metadata.
In cases where you need to clear the flag manually, however, the
following procedures outline the steps to manually clear the jumbo
flag.
Procedures¶
Divisible Chunks¶
The preferred manual way to clear the jumbo
flag from a chunk is to
attempt to split the chunk. If the chunk is divisible, MongoDB removes
the flag upon successful split of the chunk.
Find the jumbo
Chunk.¶
Run sh.status(true)
to find the chunk labeled
jumbo
.
For example, the following output from sh.status(true) shows that
chunk with shard key range { "x" : 2 } -->> { "x" : 4 }
is
jumbo
.
Split the jumbo
Chunk.¶
Use either sh.splitAt()
or sh.splitFind()
to
split the jumbo
chunk.
MongoDB removes the jumbo
flag upon successful split of the
chunk.
Indivisible Chunks¶
In some instances, MongoDB cannot split the no-longer jumbo
chunk,
such as a chunk with a range of single shard key value. As such, you
cannot split the chunk to clear the flag.
In such cases, you can either refine the shard key so that the chunk can become divisible or manually clear the flag.
Refine the Shard Key¶
Starting in 4.4, MongoDB provides the
refineCollectionShardKey
command. Using the
refineCollectionShardKey
command, you can refine a
collection’s shard key by adding a suffix field or fields to the
existing key. By adding new field(s) to the shard key, indivisible
jumbo chunks can become divisible.
Find the jumbo
Chunk.¶
Run sh.status(true)
to find the chunk labeled
jumbo
.
For example, the following output from sh.status(true)
shows that for the sharded collection test.orders
,
both the chunk with shard key range { "status" : "A" } -->> {
"status" : "D" }
and the chunk with range { "status" : "D" }
-->> { "status" : "P" }
are jumbo
.
Refine the Shard Key for test.orders
Collection.¶
To address the low cardinality of the key status
, refine the key
for the test.orders
collection. For example, add the
order_id
and customer_id
fields as a suffix to the current
shard key; i.e. the shard key will be { status: 1, order_id: 1,
customer_id: 1 }
after refinement.
First,
create the index
to support the shard key{ status: 1, order_id: 1, customer_id: 1 }
if the index does not already exist.For additional index considerations for refining the shard key, see Index Considerations.
In the
admin
database, run therefineCollectionShardKey
command to add theorder_id
andcustomer_id
fields as a suffix to the existing key:
The refineCollectionShardKey
command updates the
chunk ranges and
zone ranges to incorporate the new
fields without modifying the range values of the existing key
fields. That is, the refinement of the shard key does not
immediately affect the distribution of chunks across shards or
zones. Any future chunk splits or migration occur as part of the
routine sharding operations.
Tip
After you refine the shard key, it may be that not all documents in the collection have the suffix field(s). To populate the missing shard key field(s), see Missing Shard Key.
Before refining the shard key, ensure that all or most documents in the collection have the suffix fields, if possible, to avoid having to populate the field afterwards.
Manually Clear the jumbo
Flag for an Indivisible Chunk¶
You can manually clear the flag using the following steps.
Important
If you clear the jumbo
flag for a chunk that still exceeds the
chunk size, MongoDB will re-label the chunk as jumbo
when
MongoDB tries to move the chunk.
- MongoDB 4.2.3 and later (4.0.15 and later)
- MongoDB 4.2.2 and earlier (4.0.14 and earlier)
Starting in version 4.2.3 and 4.0.15, MongoDB provides the
clearJumboFlag
command to manually clear the
jumbo
flag.
Important
Only use this method if the preferred method is not applicable.
Find the jumbo
Chunk.¶
Run sh.status(true)
to find the chunk labeled
jumbo
.
For example, the following output from sh.status(true) shows that
chunk with shard key range { "x" : 2 } -->> { "x" : 3 }
is
jumbo
.
Run the clearJumboFlag
Command.¶
From the admin
database, run the clearJumboFlag
,
passing in the namespace of the sharded collection and either:
the bounds of the
jumbo
chunk:the find document with a shard key and value contained in the
jumbo
chunk:Note
If the collection uses a hashed shard key, do not use the
find
field withclearJumboFlag
. For hashed shard keys, use thebounds
field instead.
Important
Only use this method if the preferred method is not applicable.
Before modifying the config database, always back up the config database.
Stop the balancer.¶
Disable the cluster balancer process temporarily, following the steps outlined in Disable the Balancer.
Find the jumbo
Chunk.¶
Run sh.status(true)
to find the chunk labeled
jumbo
.
For example, the following output from sh.status(true) shows that
chunk with shard key range { "x" : 2 } -->> { "x" : 3 }
is
jumbo
.
Update chunks
collection.¶
In the chunks
collection of the config
database, unset the
jumbo
flag for the chunk. For example,
Clear the cached routing information.¶
After the jumbo flag has been cleared out from the chunks
collection, update the cluster routing metadata cache.
- Starting in MongoDB 4.0.6 (and 3.6.11),
You must flush the cache on the config server primary for the namespace. This notifies the balancer of the jumbo flag clearance.
Connect a
mongo
shell to the config server primary and runflushRouterConfig
for the collection:- In earlier versions (MongoDB 3.4-series, MongoDB 3.6.0-3.6.10, MongoDB 4.0.0-4.0.5),
- Step down the config server primary to clear the routing metadata cache from the config servers.
See also