Query data exception caused by inconsistent MongoDB data

Here I regard the state of the query as 0, but the state of the previous pieces of data is not 0. The solution is to repair the database.

db.repairDatabase()

As for the reason for the inconsistency of the data, I still don't know.

It may be that in the program, the linked database is not operating the database in safe mode

The following is the link database operation database in safe mode

MongoClient client = new MongoClient();
client.setWriteConcern(WriteConcern.SAFE);


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325915530&siteId=291194637