Migrate Data into a Time Series Collection throws an error "taking collection lock for timeseries is not allowed"

Hello,

I’m a newbie with MongoDB.
I read in the limitation of timeseries “You cannot use the $out or aggregation pipeline stages to add data from another collection to a time series collection.”

But in the documentation “Migrate Data into a Time Series Collection”, the example uses $out.

When I write like in the example (with the version MongoDB 7.0.1):

$out: {
       db: "mydatabase",
       coll: "weathernew",
       timeseries: {
         timeField: "ts",
         metaField: "metaData"
       }
     }

I have the error: $out supports only db and coll.

When I remove the field “timeseries”, I read the error “error during aggregation :: caused by :: Taking mydatabase.weathernew lock for timeseries is not allowed”.

My question:
Can I use $out like the documentation “Migrate Data into a Time Series Collection”?
If yes, how can I resolve the error about the “lock for timeseries”?

Thanks.

Hi @Karima_Rafes and welcome to MongoDB community forums!!

Using $out to Time Series collection has been updated in MongoDB version 7.0.3.

The documentation “Migrate Data into a Time Series Collection” now recommends using $out to a “non-Time Series” collection to correctly transform data for a Time Series collection.
Prior to version 7.0.3, you will have to migrate the data using mongodump and mongorestore to the time series collection. The detailed steps are mentioned in the documentation for MongoDB version 6.0.

I understand the documentation does not clarify the version and this has been raised internally.

However, to answer your questions:
1.

If you are on version 7.0.3 and above, the answer would be yes. But prior to version 7.0.3, you will have to use to the dump/restore method to migrate.

Let us know if you have any further questions.

Warm Regards
Aasawari

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.