Steps to reproduce (documents are simplified to give you the idea):
1. 10.10.0.222 is Primary, 10.10.0.223 is Secondary, and 10.10.0.155 is Arbiter.
2. Start writing 5000 requests and response documents
Requests are like:
db.mt_messages.update(
{key:Value}
, {$set:{req:ReqValue}}, true, false)
Responses are like:
db.mt_messages.update(
{key:Value}
, {$set:{resp:RespValue}}, true, false)
Both requests and responses are upserts to when they are both received the documents should look like:
{key:Value, req:ReqValue, resp:RespValue}
3. Kill 10.10.0.222 which is Primary
4. 10.10.0.223 becomes Primary
5. 10.10.0.223 Y which is Primary
6. Start 10.10.0.222 with replSet
7. 10.10.0.222 becomes Primary
8. Start 10.10.0.223 without replSet and make export
$ mongoexport -d kelly_2013_01_01 -c mt_messages -o mt_messages.json
9. Stop 10.10.0.223
10. Start 10.10.0.223 with replSet
11. 10.10.0.223 rollbacks as expected and becomes Secondary
12. After applying all rollbacks I end up with lost data even though the missing data exist in the export file mt_messages.json.
Now let's see the data.
kelly:PRIMARY> db.mt_messages.count()
5000
kelly:PRIMARY> db.mt_messages.find({rqt:{$exists:false}}).count()
31
kelly:PRIMARY> db.mt_messages.find({rps:{$exists:false}}).count()
5000
kelly:PRIMARY> db.mt_messages.find({rqt:{$exists:false}})
{ "_id" : ObjectId("5167c605efb160392cf4fbc2"), "imi" : "11589144", "omi" : "11582862", "ri" : "25dfe2d6-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.745Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbb6"), "imi" : "11589157", "omi" : "11582851", "ri" : "25e77082-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.486Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbbb"), "imi" : "11589154", "omi" : "11582857", "ri" : "25e6a206-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.583Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbbc"), "imi" : "11589151", "omi" : "11582859", "ri" : "25e4cc38-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.623Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbba"), "imi" : "11589153", "omi" : "11582854", "ri" : "25e6233a-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.522Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbbe"), "imi" : "11589143", "omi" : "11582858", "ri" : "25dee606-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.647Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbb8"), "imi" : "11589152", "omi" : "11582853", "ri" : "25e57e44-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.502Z") }
{ "_id" : ObjectId("5167c604efb160392cf4fbbf"), "imi" : "11589137", "omi" : "11582865", "ri" : "25dd3b76-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:53.673Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbe6"), "imi" : "11589102", "omi" : "11582905", "ri" : "25cf1b72-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.173Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbe7"), "imi" : "11589105", "omi" : "11582906", "ri" : "25d0161c-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.169Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbe5"), "imi" : "11589113", "omi" : "11582897", "ri" : "25d3438c-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.167Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbe2"), "imi" : "11589114", "omi" : "11582895", "ri" : "25d371d6-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.151Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbe0"), "imi" : "11589112", "omi" : "11582896", "ri" : "25d2f706-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.153Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbe1"), "imi" : "11589118", "omi" : "11582892", "ri" : "25d4d4fe-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.148Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbde"), "imi" : "11589115", "omi" : "11582893", "ri" : "25d3be5c-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.133Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbdf"), "imi" : "11589119", "omi" : "11582891", "ri" : "25d560b8-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.127Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbda"), "imi" : "11589116", "omi" : "11582889", "ri" : "25d43594-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.114Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbd9"), "imi" : "11589127", "omi" : "11582885", "ri" : "25d8f070-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.113Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbd7"), "imi" : "11589122", "omi" : "11582882", "ri" : "25d77d3a-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.093Z") }
{ "_id" : ObjectId("5167c605efb160392cf4fbd5"), "imi" : "11589131", "omi" : "11582869", "ri" : "25db5f2c-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" : ISODate("2013-01-02T18:02:54.090Z") }
Type "it" for more
kelly:PRIMARY>
We miss 31 updates.
Search the first "imi":"11589144" which is unique enough for this purpose.
on 10.10.0.222 the response is registered.
$ grep 11589144 /var/log/mongodb.log
Fri Apr 12 11:29:57.026 [conn29] update kelly_2013_01_01.mt_messages query:
{ ri: "25dfe2d6-a34b-11e2-994b-000c29a75b4d", imi: "11589144" }
update: { $set:
{ omi: "11582862", rpt: new Date(1357149773745), rps: "success" }
} nscanned:0 nupdated:1 fastmodinsert:1 keyUpdates:0 locks(micros) w:148 0ms
on 10.10.0.223 the request is registered.
$ grep 11589144 /var/log/mongodb.log
Fri Apr 12 11:30:12.765 [conn18] update kelly_2013_01_01.mt_messages query:
{ ri: "25dfe2d6-a34b-11e2-994b-000c29a75b4d", imi: "11589144" }
update: { $set: { ct: "funnel", ci: "493b3678-9dc8-11e2-8cce-00269e42f7a5", ui: "user", gi: "7dc235d0-c938-4b66-8f8c-c9037c7eace7", t: "regular", e: "default", b: "User", sa:
{ a: "375296660002", t: 1, n: 1 }
, da:
{ a: "375293615363", t: 1, n: 1 }
, rd: false, rqt: new Date(1357149779760) } } nscanned:1 nmoved:1 nupdated:1 keyUpdates:0 locks(micros) w:433 0ms
on 10.10.0.223 whole document is available according to the export file
$ grep 11589144 mt_messages.json
{ "_id" :
{ "$oid" : "5167c605efb160392cf4fbc2" }
, "b" : "User", "ci" : "493b3678-9dc8-11e2-8cce-00269e42f7a5", "ct" : "funnel", "da" :
{ "a" : "375293615363", "t" : 1, "n" : 1 }
, "e" : "default", "gi" : "7dc235d0-c938-4b66-8f8c-c9037c7eace7", "imi" : "11589144", "omi" : "11582862", "rd" : false, "ri" : "25dfe2d6-a34b-11e2-994b-000c29a75b4d", "rps" : "success", "rpt" :
{ "$date" : 1357149773745 }
, "rqt" :
{ "$date" : 1357149779760 }
, "sa" :
{ "a" : "375296660002", "t" : 1, "n" : 1 }
, "t" : "regular", "ui" : "user" }
on 10.10.0.223
$ bsondump kelly_2013_01_01.mt_messages.2013-04-12T08-31-25.0.bson 2>/dev/null | grep 11589144
IT'S NOT HERE! IT'S GONE!