Capped Collection changed to uncapped suddenly

Hello Team

We have created a capped collection and spring DefaultMessageListenerContainer (registered with TailableCursorRequest) listening to the capped collection. Everything works good till yesterday. From today we are getting below errors

MongoError: tailable cursor requested on non capped collection

Collection statistics for the capped collection shows capped property is false. We don’t know why / when suddenly capped collection converted into a non capped collection.

Can some one help us to understand why suddenly it changed to non capped collection ?

Mongodb 4.0.6
Spring 2.2.4.RELEASE

:wave:

Hi @Prabaharan_Kathiresa something like that shouldn’t happen all by itself. Did someone accidentally drop the collection and then rebuild it?

As for troubleshooting, I would look through the log files to see if there is something in there that would help you determine what might have happened.

You can convert the back to a capped collection if you’re not on a sharded cluster.

2 Likes

Below are the different exception log statements available

[cTaskExecutor-1] rContainer$DecoratingLoggingErrorHandler : Unexpected error occurred while listening to MongoDB

Proj: {}
tailable cursor requested on non capped collection’ on server :27130; nested exception is com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'error processing query: ns=db.cappedCollectionTree: createdDate $gt new Date(1590194803434)

org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message 'error processing query: ns=db.cappedCollectionTree: createdDate $gt new Date(1590194803434)

Caused by: com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'error processing query: ns=db.cappedCollectionTree: createdDate $gt new Date(1590194803434)

Welcome to the community forum @Prabaharan_Kathiresa!

A capped collection cannot be converted to an uncapped collection. As @Doug_Duncan suggested, the most likely cause would be a collection being dropped & recreated with the same name. If the collection being tailed was dropped, this should also correlate with any associated cursors being closed.

The log snippets you provided are application logs. The timestamps for errors in your application log may help you work out the relevant time period, but to investigate further you need to look into your MongoDB server log activity.

Try searching your MongoDB logs for lines matching CMD: drop . Unless you have changed the log settings, a drop command should be logged at the default level in MongoDB 4.0.

Can you also confirm what type of deployment you have (standalone, replica set, or sharded cluster)?

Regards,
Stennie

Thank you @Stennie_X and @Doug_Duncan.

We are using replica set deployment.