What happens to a query during shard balancing, and how is this managed?

One thing that is not covered in the shard chapter is what happens to queries during shard balancing? Is mongos aware of the balancing and hold queries, or are they scatter-gathered, or some other behavior?

Sorry for the repost. Deleted my original because I thought I had found the answer but had not.

Hi :wave: @Jonathon_Anderson,

Welcome to the MongoDB Community forums :sparkles:

Let us give you some background first:

The Config servers store the metadata for a sharded cluster. The metadata reflects the state and organization of all data and components within the sharded cluster. And, the mongos instances cache this data and use it to route read and write operations to the correct shards.

Here, the mongos is used as the cluster endpoint and acts as an interface between the client and the shards. It is essentially a router that sends client (application) requests to the relevant shards and aggregates the result from shards into a consistent client response.

So, whenever the shard balancing happens - the balancer migrate chunks between shards and while chunks are being migrated, mongos while serve from the source/donor shard, until the migration completes.

For more info, please refer to our documentation: Sharding - MongoDB

If you have any doubts, please feel free to reach out to us.

Regards.
Kushagra Kesav