Skip to content

Commit d81815e

Browse files
committed
Merged
2 parents 13735ba + e10a9be commit d81815e

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

lib/db.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,10 @@ var createIndex = function(self, name, fieldOrSpec, options, callback) {
10721072
// 67 = 'CannotCreateIndex' (malformed index options)
10731073
// 85 = 'IndexOptionsConflict' (index already exists with different options)
10741074
// 11000 = 'DuplicateKey' (couldn't build unique index because of dupes)
1075+
// 11600 = 'InterruptedAtShutdown' (interrupted at shutdown)
10751076
// These errors mean that the server recognized `createIndex` as a command
10761077
// and so we don't need to fallback to an insert.
1077-
if(err.code === 67 || err.code == 11000 || err.code === 85) {
1078+
if(err.code === 67 || err.code == 11000 || err.code === 85 || err.code == 11600) {
10781079
return handleCallback(callback, err, result);
10791080
}
10801081

test/functional/apm_tests.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,3 +1025,30 @@ exports['Ensure killcursor commands are sent on 3.0 or earlier when APM is enabl
10251025
});
10261026
}
10271027
}
1028+
1029+
exports['Ensure killcursor commands are sent on 3.0 or earlier when APM is enabled'] = {
1030+
metadata: { requires: { topology: ['single', 'replicaset'] } },
1031+
1032+
// The actual test we wish to run
1033+
test: function(configuration, test) {
1034+
var started = [];
1035+
var succeeded = [];
1036+
var failed = [];
1037+
var callbackTriggered = false;
1038+
1039+
var listener = require('../..').instrument(function(err, instrumentations) {});
1040+
var db = configuration.newDbInstance({w:1}, {poolSize:1, auto_reconnect:false});
1041+
db.open(function(err, db) {
1042+
var collection = db.collection('apm_killcursor_tests_1');
1043+
1044+
// make sure collection has records (more than 2)
1045+
collection.insert({}, function(err, r) {
1046+
test.equal(null, err);
1047+
1048+
listener.uninstrument();
1049+
db.close();
1050+
test.done();
1051+
});
1052+
});
1053+
}
1054+
}

test/functional/replset_failover_tests.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,3 +591,61 @@ exports['Should get proper error when strict is set and only a secondary is avai
591591
});
592592
}
593593
}
594+
595+
// /**
596+
// * @ignore
597+
// */
598+
// exports['Should correctly re-execute createIndex against primary after step-down'] = {
599+
// metadata: { requires: { topology: 'replicaset' } },
600+
601+
// test: function(configuration, test) {
602+
// // The state
603+
// var manager = configuration.manager;
604+
605+
// var db = configuration.newDbInstance({w:1}, {poolSize:1});
606+
// db.open(function(err, db) {
607+
// db.once('fullsetup', function() {
608+
// // Wait for close event due to primary stepdown
609+
// db.serverConfig.on('joined', function(t, d, s) {
610+
// if(t == 'primary') console.log("primary joined " + s.name)
611+
// });
612+
613+
// db.serverConfig.on('left', function(t, s) {
614+
// if(t == 'primary') {
615+
// }
616+
// });
617+
618+
// manager.primary().then(function(primary) {
619+
// primary.stop(9).then(function() {
620+
// });
621+
622+
// // // Execute createIndex
623+
// // db.collection('t').createIndex({'accessControl.get': 1}, {background: true}, function(err, r) {
624+
// // console.dir(err)
625+
// // console.dir(r)
626+
627+
// // test.ok(err != null);
628+
// // test.ok(err.message.indexOf('key accessControl.get must not contain') == -1);
629+
630+
// // db.close();
631+
// // test.done();
632+
// // });
633+
634+
// setTimeout(function() {
635+
// // Execute createIndex
636+
// db.collection('t').createIndex({'accessControl.get': 1}, {background: true}, function(err, r) {
637+
// console.dir(err)
638+
// console.dir(r)
639+
640+
// test.ok(err != null);
641+
// test.ok(err.message.indexOf('key accessControl.get must not contain') == -1);
642+
643+
// db.close();
644+
// test.done();
645+
// });
646+
// }, 100);
647+
// });
648+
// });
649+
// });
650+
// }
651+
// }

0 commit comments

Comments
 (0)