How to Fix MongoDB Error 117 (ConflictingOperationInProgress)
You get mongodb error 117 when two tasks try to change the same resource at once. To fix this ConflictingOperationInProgress failure, wait for the first task to finish before running the next one. Database engines use locks and state checks to protect your data from corruption. When two admin commands clash on one collection, the database stops the second command right away. This fast failure keeps your schema and indexes safe during heavy work. What causes mongodb error 117 in your cluster
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 117 when two tasks try to change the same resource at once. To fix this ConflictingOperationInProgress failure, wait for the first task to finish before running the next one.
Database engines use locks and state checks to protect your data from corruption. When two admin commands clash on one collection, the database stops the second command right away. This fast failure keeps your schema and indexes safe during heavy work.
What causes mongodb error 117 in your cluster
The official name for mongodb error 117 is ConflictingOperationInProgress. The database throws this code when a new task fights with an active task. Both tasks want exclusive control over the exact same database or collection.
Index builds and collection drops often trigger this clash in busy clusters. For example, one script might start building an index on a large collection. Before it finishes, a second deploy script tries to drop that same index.
Sharded clusters can also hit this error during chunk moves or balancing runs. If an engineer triggers a manual move while the balancer runs, the cluster blocks the second request. Automated deploy pipelines cause this problem when two jobs run at the same time.
Human error is another common trigger during live incidents. Two engineers might log in and run fix scripts on one collection at the same time. Without a central queue or approval step, their commands collide inside the engine.
How to diagnose and fix the failure safely
Start by checking which tasks are running on your cluster right now. Look for active index builds, collection drops, or chunk moves on the target namespace. Most of the time, the safest fix is to wait for the active task to finish.
Do not kill a running task unless you know it is stuck or broken. Stopping a schema change midway can leave your collection in a messy state. Instead, add retry logic with a short wait time to your deploy scripts.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You should also review who can run heavy commands in your production cluster. MongoDB grants access through roles that define allowed actions on specific resources. You can scope these roles down to a single database or collection level.
Give most engineers the built-in read role for daily checks and debugging. The read role allows safe actions like find, listCollections, listIndexes, dbStats, and collStats. It blocks actions that change data or structure, such as dropCollection.
Reserve the readWrite role for users and apps that must change data. The readWrite role includes read actions plus createCollection, createIndex, dropIndex, and dropCollection. Because these actions can trigger conflicts, limit how many accounts hold this role.
How to prevent conflicting operations in production
Good access habits stop conflicting commands before they ever reach your database. First, run all index and collection changes through a single deploy pipeline. Make sure your pipeline runs one database job at a time using a queue.
Second, separate everyday data checks from heavy schema changes. Engineers who only need to inspect data should use read-only roles by default. When someone needs to create or drop an index, require a peer review first.
Third, keep sensitive data safe while engineers inspect active issues. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in query results. This lets your team check collection state and fix errors while keeping private fields protected.
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
Does mongodb error 117 mean my data is corrupted?
No, this error actually protects your data from corruption. The database blocks the second command so the first task can finish cleanly. Once the active task ends, you can safely run your next command.
Can read-only queries trigger ConflictingOperationInProgress?
Standard read actions like find or listIndexes rarely cause this specific conflict error. The error almost always comes from two write or admin tasks clashing on one resource. Using the read role for routine checks helps avoid these clashes.
Should I grant full admin rights to fix stuck operations faster?
No, giving out broad admin roles increases the risk of more overlapping commands. Keep engineers on the read role and grant higher access only for approved tasks. Always coordinate across your team before stopping or restarting a database job.
Related guides
In this post