How to Fix MongoDB Error 350 (ReshardCollectionTruncatedError)
You get mongodb error 350 when a collection is truncated or dropped during resharding. To fix thisReshardCollectionTruncatedError, stop conflicting write commands and run the resharding job again. Database teams often see this failure during big schema updates or data cleanup tasks. When two admin tasks clash on the same collection, the cluster protects your data. It stops the resharding job right away and sends back this error code. What causes mongodb error 350 in your cluster MongoDB maps
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mongodb error 350 when a collection is truncated or dropped during resharding. To fix thisReshardCollectionTruncatedError, stop conflicting write commands and run the resharding job again.
Database teams often see this failure during big schema updates or data cleanup tasks. When two admin tasks clash on the same collection, the cluster protects your data. It stops the resharding job right away and sends back this error code.
What causes mongodb error 350 in your cluster
MongoDB maps code 350 to the official name ReshardCollectionTruncatedError inside the database engine. Resharding copies data from your old shard layout into a brand new collection layout. While that copy runs, the engine watches the source collection for major changes.
If a user or script drops or clears the source collection, the copy fails. The cluster cannot finish moving data because the base records are now gone. It aborts the resharding work and logs code 350 to alert the admin team.
Automated cleanup scripts are the most common cause of this sudden conflict in production. A scheduled job might clear old test data while an engineer reshards the collection. Another cause is an app deployment that resets staging or temp tables on startup.
Broad database permissions make this problem happen much more often in busy teams. In MongoDB, roles grant privileges to run specific actions on defined resources. A role applies to its target database and works down to the collection level.
The built-in readWrite role lets users modify data across all non-system collections. Its allowed actions include insert, update, remove, and even the dropCollection action. If too many accounts hold this role, someone can drop a collection during resharding.
How to diagnose and fix the failure in production
Start by checking your database logs to see what stopped the resharding process. Look for drop or truncate events that happened at the exact same timestamp. Identify which user account or app service sent that conflicting command to the cluster.
Do not grant broad admin permissions to your engineers just to inspect these logs. Give the investigating engineer the built-in read role on the target database instead. The read role allows safe inspection actions like find, listCollections, listIndexes, dbStats, and collStats.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Crucially, the read role does not include insert, update, remove, or dropCollection actions. This keeps your team from making the problem worse while they check the cluster. If the collection contains private data, make sure your query tools protect those fields.
Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs. Engineers can check collection stats and sample documents while keeping sensitive user records safe. Once you find the conflicting script or cron job, pause it before you retry.
Next, check the state of the target collection to see if data was lost. If a script dropped the collection by mistake, restore the missing data from backup. Verify that all collection indexes and shard keys match your planned cluster design.
Before you start the resharding job again, tighten your role setup on that database. Move daily users and background apps off the broad readWrite role when possible. Build custom roles that grant access down to a single collection level instead.
How to prevent resharding conflicts during maintenance
Remove the dropCollection action from app roles that only need to read or write. Schedule your resharding work during quiet hours when batch cleanup jobs do not run. Coordinate with your app teams so no one pushes schema changes during the move.
When the cluster is quiet and roles are locked down, start resharding again. Watch the progress metrics until the cluster finishes the move and swaps the collection. Once the job finishes, you can turn your paused background scripts back on.
Inspect MongoDB wire traffic in flight
Built-in MongoDB roles govern collection access at setup time. They cannot score command risk per call or mask sensitive document values on the fly. By design, hoop.dev sits inline in the MongoDB protocol next to your server as a sidecar for your MongoDB. On every production command from mongosh, drivers, or AI agents, hoop.dev decides whether to pass, mask, block, or hold it for human review.
First, hoop.dev guardrails block bad deletes, drops, and write pipelines or hold them for approval. Next, hoop.dev data masking rewrites sensitive values in returned documents in memory and logs each decision. Explore the repo on GitHub.
Frequently asked questions
What does ReshardCollectionTruncatedError mean in MongoDB?
It means the database stopped a resharding job because the source collection was truncated. The cluster aborts the move safely and returns code 350 to the client.
Does mongodb error 350 corrupt my existing cluster data?
No, the resharding abort itself does not corrupt your remaining database records. Still, the separate command that truncated or dropped your collection did remove data.
How can I stop apps from dropping collections during resharding?
Avoid giving the full readWrite role to apps since it includes the dropCollection action. Create a custom role scoped to the collection without permission to drop or truncate.
Related guides
In this post