Home > database >  Mongo insert error: E11000 duplicate key error collection
Mongo insert error: E11000 duplicate key error collection

Time:09-16


Mongo insert data appear a large number of error, an error to stop before application, there are also delete data,
Directing is a single instance,
Error fields for directing a own _id, before understanding _id is timestamp + host + + sequence of processes,

Can you tell me the time stamp is? Feeling not the time to read the application of the host, if is the host of time, will not repeat the timestamp, but now is repeated,

Delete the script:
Db. TL_USER. Remove ({" CODE ":" 13 "});


 
Com. The mongo. MongoWriteException: E11000 duplicate key error collection: mongo_act. TL_USER index: _id_ dup key: {: ObjectId (' 57 eb370ba832606bf4fa9c22 ')}
At com. Mongo. MongoCollectionImpl. ExecuteSingleWriteRequest (MongoCollectionImpl. Java: 523)
At com. Mongo. MongoCollectionImpl. InsertOne (MongoCollectionImpl. Java: 306)
At com. Mongo. MongoCollectionImpl. InsertOne (MongoCollectionImpl. Java: 297)
At com. Cucc. Ogg. Example. Excute (698) Example. Java:
At com. Cucc. Ogg. Example. ProductMain (283) Example. Java:
At com. Cucc. Ogg. Example. The main (1035) Example. Java:

CodePudding user response:

1 look at the _id where the
2 look at the time
57 eb85b6bd096390f5c634c2 ObjectId (" "). GetTimestamp ()
ISODate (2016-09-28 T08:56:22 "Z")

CodePudding user response:

If there is only one primary key repeat custom?

CodePudding user response:

Should be the custom repeated, timestamp generated id will not be repeated

CodePudding user response:

Is how to solve this problem, and how, I now also appear this kind of circumstance, is roughly the flume to read at the same time generate log,
Because the channel sink every time to get a log, if every time to get the log is executed once inserted, was once a is no problem
But if these logs to a cumulative, as the number of log access to reach a certain value, the insertion, can appear abnormal id,
How to solve

CodePudding user response:

Use findOneAndUpdate or update update will quote name or _id errors, updated but I don't understand why this problem? Please the great god solution
  • Related