Skip to content

Documents in Capped Collections should not be modified #1847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions source/core/capped-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,31 @@ collections:
Recommendations and Restrictions
--------------------------------

- You *can* update documents in a collection after inserting
them. *However,* these updates **cannot** cause the documents to
grow. If the update operation causes the document to grow beyond
their original size, the update operation will fail.
- You can only make in-place updates of documents. If the update operation
causes the document to grow beyond their original size, the update
operation will fail.

If you plan to update documents in a capped collection, create an
index so that these update operations do not require a table scan.

- If you update a document in a capped collection to a size smaller than
its original size, and then a secondary resyncs from the primary, the
secondary will replicate and allocate space based on the current smaller
document size. If the primary then receives an update which increases
the document back to its original size, the primary will accept
the update but the secondary will fail with a ``failing update: objects
in a capped ns cannot grow`` error message.

To prevent this error, create your secondary from a snapshot of one
of the other up-to-date members of the replica set. Follow :doc:`our
tutorial on filesystem snapshots
</tutorial/backup-with-filesystem-snapshots>` to seed your new secondary.

Seeding the secondary with a filesystem snapshot is the only way to
guarantee the primary and secondary binary files are compatible; i.e.
BRS snapshots are insufficient in this situation since you need more
than the content of the secondary to match the primary.

- You cannot delete documents from a capped collection. To remove all
records from a capped collection, use the 'emptycapped' command. To
remove the collection entirely, use the :method:`~db.collection.drop()`
Expand Down