Created
December 2, 2012 23:39
-
-
Save Tug/4191595 to your computer and use it in GitHub Desktop.
issue with node-mongodb-native commit 5fd127e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function openFile(db, filename, callback) { | |
var gs = new mongodb.GridStore(db, filename, "r"); | |
gs.open(function(err, gs) { | |
if(err) { | |
callback(err, gs); | |
return; | |
} | |
callback(null, gs); | |
}); | |
} | |
var Step = require('step'); | |
var retryAsync = function(func, num, errorCallback) { | |
var actions = []; | |
for(var i=0; i<num; i++) actions.push(func); | |
actions.push(errorCallback); | |
Step.apply(null, actions); | |
} | |
retryAsync(function() { | |
var retry = this; | |
openFile(db, filename, function(err, gs) { | |
if(err || !gs) { | |
setTimeout(retry, 2000); | |
return; | |
} | |
next(null, gs); | |
}); | |
}, 5, function() { | |
error(err || new Error('GrowingFile not found')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"server" : { | |
"auto_reconnect": true | |
} | |
, "replset" : { | |
"rs_name" : "rs0" | |
, "read_secondary" : true | |
} | |
, "db" : { | |
"safe" : { "w": 3, "wtimeout": 5000 } | |
} | |
, "user" : "nochan" | |
, "pass" : "CHANGE_HERE" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rs0:PRIMARY> rs.status() | |
{ | |
"set" : "rs0", | |
"date" : ISODate("2012-12-02T23:27:25Z"), | |
"myState" : 1, | |
"members" : [ | |
{ | |
"_id" : 0, | |
"name" : "instance1.nochan.fr:27017", | |
"health" : 1, | |
"state" : 1, | |
"stateStr" : "PRIMARY", | |
"uptime" : 617262, | |
"optime" : Timestamp(1354490596000, 2), | |
"optimeDate" : ISODate("2012-12-02T23:23:16Z"), | |
"self" : true | |
}, | |
{ | |
"_id" : 2, | |
"name" : "instance3.nochan.fr:27017", | |
"health" : 1, | |
"state" : 2, | |
"stateStr" : "SECONDARY", | |
"uptime" : 616759, | |
"optime" : Timestamp(1354490596000, 2), | |
"optimeDate" : ISODate("2012-12-02T23:23:16Z"), | |
"lastHeartbeat" : ISODate("2012-12-02T23:27:24Z"), | |
"pingMs" : 0 | |
}, | |
{ | |
"_id" : 3, | |
"name" : "instance2.nochan.fr:27017", | |
"health" : 1, | |
"state" : 2, | |
"stateStr" : "SECONDARY", | |
"uptime" : 616371, | |
"optime" : Timestamp(1354490596000, 2), | |
"optimeDate" : ISODate("2012-12-02T23:23:16Z"), | |
"lastHeartbeat" : ISODate("2012-12-02T23:27:24Z"), | |
"pingMs" : 0 | |
} | |
], | |
"ok" : 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you never want to do w:3 because that means that every single write will fail if you have to take down 1 single server for maintenance. you can use w:'majority' instead if you want but w:2 is nearly always enough for most people.
I'll look into the other stuff later today.