How to Fix MongoDB Error 367 (FLECompactionPlaceholder)

Published
Length
3 min read

Luis Felipe Dias

All posts

You see mongodb error 367 when field-level encryption compaction hits an internal placeholder state. To fix it, check your client driver setup and retry the compaction step. MongoDB names this failure FLECompactionPlaceholder in its official error catalog. It happens during maintenance tasks on collections that use encrypted fields. Database teams must understand how encrypted metadata works before they run repair steps. What causes mongodb error 367 in your cluster The database engine throw

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 367 when field-level encryption compaction hits an internal placeholder state. To fix it, check your client driver setup and retry the compaction step.

MongoDB names this failure FLECompactionPlaceholder in its official error catalog. It happens during maintenance tasks on collections that use encrypted fields. Database teams must understand how encrypted metadata works before they run repair steps.

What causes mongodb error 367 in your cluster

The database engine throws code 367 when a compaction task hits a placeholder state. Field-level encryption stores special metadata inside internal collections alongside your normal records. Compaction jobs clean up old metadata tokens to save disk space. If a client or server interrupts this process, the engine flags the placeholder error.

Several setup problems can trigger this specific state in a cluster. First, the client driver and the server might run mismatched encryption routines. Second, a network drop can break the link between the app and the cluster. Third, another user might change the target collection while compaction runs.

Role limits also play a large part in how these tasks fail. MongoDB grants access through roles that allow sets of actions on specific resources. A role applies to its home database and works down to the collection level. Self-hosted users and cloud database users have different built-in roles. Still, both sets of roles use the exact same core privilege actions. If a user lacks the right action on an internal collection, compaction stops.

How to diagnose and fix FLECompactionPlaceholder

Start your check by reading the server logs around the exact failure time. Look for stopped background jobs or network resets from the app host. You only need a basic read role to inspect collection states first. The read role grants access to all non-system collections in its database. It lets you run find, listCollections, listIndexes, dbStats, collStats, and changeStream actions. It blocks insert, update, remove, and dropCollection actions so production data stays safe.

Next, check if an active write job clashes with your maintenance window. Compaction needs to update and remove old metadata records inside the target database. The readWrite role includes all read actions plus the power to change data. Its actions include insert, update, remove, createCollection, createIndex, dropIndex, and dropCollection. Make sure the service account running the compaction job holds these needed write actions.

MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Do not grant full cluster admin rights just to clear error 367. Instead, scope the role down to the exact database and collection level. Pause heavy write apps for a short time while you retry the compaction. Check your client setup to ensure all encryption keys are active and reachable. Once the network path is stable and permissions match, run the compaction task again.

Preventing encryption compaction failures in production

You can avoid future compaction errors by setting clear rules for database maintenance. Schedule all encryption cleanup jobs during quiet hours with low write traffic. Keep your client drivers updated so they handle placeholder states the right way.

Audit your database roles often to keep user access tight and safe. Give engineers the read role for daily checks and log reviews. Only assign the readWrite role to trusted jobs that must change records. Adding field masking for emails, phone numbers, card numbers, and national IDs helps too. Masking rewrites matched fields in query results during daily checks.

Add command guardrails and field masking beside MongoDB

Collection roles and IP rules control who connects to MongoDB. Yet an active client or agent session can still run a pipeline that writes data or reads raw personal fields. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your MongoDB. For every command an agent or human sends in production, hoop.dev decides to pass, mask, block, or escalate it for review.

Using hoop.dev MongoDB controls, guardrails refuse banned commands before they run or hold risky calls for approval, and data masking rewrites matched fields in returned documents in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for GDPR, HIPAA, and PCI DSS programs. View the project on GitHub.

Frequently asked questions

What does the FLECompactionPlaceholder error name mean?

It is the official MongoDB name for error code 367. It points to a placeholder state during field-level encryption metadata compaction.

Can a user with the read role fix error 367?

No, the read role only allows actions like find, listCollections, and collStats. Fixing compaction requires write actions like update and remove from the readWrite role.

Does mongodb error 367 mean my encrypted data is lost?

No, this error means a cleanup or compaction step stopped early. Your core records remain safe, and you can retry the task after checking permissions.

The query runs. The emails stay hidden.