Scenario : I need to insert a record in collection A & then along with the _ids of that inserted record from collection A , i need to insert another record in collection B .
For ex - After insertion
Collection A record
{ _id: ObjectId(“abcdef”) , name: “L” , records : [ { id: “def” , name : “none” } ] }
Collection B record
{ _id: ObjectId(“b_collection_id”) , a_col_id : ObjectId(“abcdef”) ,
b_records : [ { id: “b_id” , a_records_id : “def” } ] }
This same process needs to be done for Millions of records but for few records insertOne in collection A gives successful response along with all the ids & then got inserted into Collection B but when we try to search the record in Collection in A it wasn’t present there but Collection B record had all the values that are required from collection A record.
Now the question here is are there known scenarios of data loss in Mongodb atlas because this has happened to me while loading 500K records & 800K records & both time the loading of records got failed because 1-3 records didn’t appear in collection A but their corresponding records in collection B got created with all the correct data format along with Collection A ids ( that somehow are not present in Collection A ).
Is there any solution to it ?
Will applying writeConcern { w: majority } options would make sure that data loss never happens ?