Lab write and Fail behaved differently from answers!

What did I miss?
I shutdown a secondary of a 3 node cluster
here is the rs.status on primary showing node 3 is not reachable
{
“_id” : 2,
“name” : “192.168.103.100:27003”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},

I then did the insert on primary and the data showed:MongoDB Enterprise m103-repl:PRIMARY> use testDatabase
switched to db testDatabase
MongoDB Enterprise m103-repl:PRIMARY> db.new_data.insert({“m103”: “very fun”}, { writeConcern: { w: 3, wtimeout: 1000 }})
WriteResult({
“nInserted” : 1,
“writeConcernError” : {
“code” : 64,
“codeName” : “WriteConcernFailed”,
“errInfo” : {
“wtimeout” : true
},
“errmsg” : “waiting for replication timed out”
}
})
MongoDB Enterprise m103-repl:PRIMARY> db.new_data.find()
{ “_id” : ObjectId(“5d66e71dbac94bce8ce8f418”), “m103” : “very fun” }
MongoDB Enterprise m103-repl:PRIMARY> exit
then I brought back the node that was shutdown
and checked the data after the rs.slaveok command:
vagrant@m103:/var/mongodb/db$ mongod -f mongod-repl-3.conf
MongoDB Enterprise m103-repl:SECONDARY> rs.slaveOk()

MongoDB Enterprise m103-repl:SECONDARY> db.new_data.find()

MongoDB Enterprise m103-repl:SECONDARY> use TestDatabase

switched to db TestDatabase

MongoDB Enterprise m103-repl:SECONDARY> db.new_data.find()

MongoDB Enterprise m103-repl:SECONDARY> exit

I went back to primary and the data had rolled back:
switched to db TestDatabase

MongoDB Enterprise m103-repl:PRIMARY> db.new_data.find()

MongoDB Enterprise m103-repl:PRIMARY>

This is in fact what I had expected given that with 2 nodes majority was not there.

However this doesn’t seem to match what the lab says i.e. that the failed node would resync its data.

Hi @ramin_tork,

Please use the correct name of the database as these are case-sensitive.
The names that you are using are different as seen below:

Please feel free to reach out in case you face any other issues.

Thanks,
Muskan
Curriculum Support Engineer

Thank you. I had missed the difference in the case. The inserted data is indeed there on all three nodes.

1 Like