Donor and recipient shards periodically update the config.reshardingOperations document on the config server as part of their state changes. Most of the DonorShardContext and RecipientShardContext types are fixed in size. The exception to this for both donor and recipient shards is the abortReason. To prevent the situation where multiple participants have an abortReason causing the update to fail with BSONObjectTooLarge, the donor and recipient shards must truncate their abortReason in the update to the config.reshardingOperations collection.
Things to consider:
- If serializeErrorToBSON() yields a BSONObj larger than 2000 bytes then the abortReason must be truncated. 2000 bytes is to be generous for when there are a large number of shards (up to 1000) that error simultaneously.
- Truncate the abortReason by doing the following:
- Serialize the Status to a string with Status::toString(). This enables the Status to partially include a serialized form of its ErrorExtraInfo if its reason is short enough.
- Truncate the string using UTF8SafeTruncation().
- Create a new Status using a new ReshardCollectionTruncatedError code with the truncated string as the error reason.