Hello. Just some thoughts on the error and its handling.
"errmsg":"E11000 duplicate key error collection: crypto.btc_ohlc_minute index: _id_ dup key: { _id: ObjectId('6255cce8bdfc280a8c8d6ee8') }"...
This error says that the unique index constraint on the
_id field is violated. Every MongoDB collection document has this mandatory field, which functions as a "primary key", is of type
ObjectId and is created by default. This value can be user supplied, optionally.
When doing a bulk insert (as using the
insertMany method), when any error occurs the operation is aborted - as in this case. But, there is an option to continue with the bulk insert even when there is an error. And you can try to use it. The insertMany has an optional parameter
ordered, and is by default
True - the process aborts when there is an error. When set to
False, the insert operation continues even when there is an error. This is useful when inserting many documents and do not need to stop the process in case of an error, like an "E11000". This kind of situation is quite common in MongoDB bulk operations.
SCJP 5, OCPJP 7, 8, SCJD 5, SCWCD 4, SCBCD 5, SCJWS 4, IBM OOAD 833 & 834, MongoDB Developer