DBAtlas · Database operations atlas

136 CappedPositionLost: Capped collection position lost

MongoDB

What does it mean?

A cursor reading a capped (fixed-size) collection (typically a tailable cursor) lost its position. The document it was positioned on no longer exists because the collection overwrote it cyclically.

Why does it happen?

When a capped collection is full, the oldest documents are removed and overwritten automatically; a tailable cursor following a collection that is written faster than it can consume falls behind and its position is overwritten. Seen in consumers that tail capped structures such as the oplog.

How to fix it

Reposition the cursor (open a new tailable cursor) and restart tailing; catch this error in the application and refresh the read. If the root cause is a consumer that cannot keep up with the write rate: increase the capped collection/oplog size or speed up the consumer. To track changes reliably, use change streams instead of tailable cursors where possible.

Open in DBAtlas →

More from this engine