How to Fix MongoDB Error 313 (ResumableRangeDeleterDisabled)
You see mongodb error 313 when a shard tries to run a disabled range deleter. You can fix it by turning the range deleter back on and letting cleanup finish. In MongoDB, code 313 maps to the official error name ResumableRangeDeleterDisabled. This error happens in sharded clusters during chunk moves and orphaned data cleanup. When a chunk moves from one shard to another, the source shard must delete old documents. If the background range deleter is turned off, the cluster throws this error code.
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 see mongodb error 313 when a shard tries to run a disabled range deleter. You can fix it by turning the range deleter back on and letting cleanup finish.
In MongoDB, code 313 maps to the official error name ResumableRangeDeleterDisabled. This error happens in sharded clusters during chunk moves and orphaned data cleanup. When a chunk moves from one shard to another, the source shard must delete old documents. If the background range deleter is turned off, the cluster throws this error code.
What causes mongodb error 313 in sharded clusters
Sharded clusters balance data by moving document ranges between shards. After a move finishes, the old shard still holds copies of those documents. We call these leftover records orphaned documents. A background service called the resumable range deleter removes them over time. If a step pauses or disables this service, the database returns ResumableRangeDeleterDisabled.
Why would this service be off in the first place? Sometimes an operator disables background cleanup during heavy traffic or a cluster upgrade. Other times, a node is still starting up or stepping down from primary status. If a migration job asks for range deletion while the service is off, the request fails. The shard logs code 313 and stops the current migration task.
This state can also block new chunk moves on the same collection. Until the old range is clean, the shard cannot take in overlapping data ranges. Your balancer might stall while it waits for the range deleter to resume work. Checking shard logs and balancer state will show if code 313 is holding up migrations.
How to diagnose and fix ResumableRangeDeleterDisabled safely
Start by checking your shard logs and cluster status with a read-only account. MongoDB uses role-based rules to grant actions down to the collection level. The built-in read role grants safe inspection actions like find, listCollections, dbStats, and collStats. It does not allow insert, update, remove, or dropCollection actions on your data. Using a read account lets your team check cluster state without risking accidental data changes.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Look for the exact shard that logged the ResumableRangeDeleterDisabled message. Check if that replica set just had a primary election or a node restart. If a node is still recovering, wait a few minutes for startup tasks to finish. Once the node settles as primary, the resumable range deleter often starts on its own.
If the error stays, check if someone turned off the range deleter on that shard. You will need a role with admin permissions to update shard settings or balancer state. Avoid giving out broad write roles like readWrite for simple cluster checks. The readWrite role allows data changes such as insert, remove, createIndex, and dropCollection. Keep diagnostic work and admin changes in separate steps with tight approvals.
When you turn the range deleter back on, watch your disk and CPU usage. Deleting many orphaned documents at once can add load to the storage engine. Let the background task clear the queue before you start big balancer runs again. Also make sure that log outputs rewrite sensitive fields like emails or card numbers.
Check MongoDB commands and documents on the wire
MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.
Frequently asked questions
What does the error name ResumableRangeDeleterDisabled mean?
It is the official name for MongoDB error code 313. It means the background task that deletes orphaned chunk ranges is turned off on a shard.
Does mongodb error 313 cause data loss on my cluster?
No, code 313 does not delete live data. It pauses the cleanup of leftover documents after a chunk move, which can slow down future balancing.
What role should engineers use to check shard status first?
Engineers should start with a read role that allows dbStats, collStats, and find actions. This keeps data safe from accidental writes or drops during a check.
Related guides
In this post