summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2015-03-11 16:34:25 -0400
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-04-20 15:01:43 -0400
commit6920a654e8bc81b602a39bb96216ba44ad7da53f (patch)
tree66bf15b3defc7cb37261b8aa6af9d00798680a6a
parent61b430008982fd97d7d0f6e8625907edf4ad84c4 (diff)
downloadmongo-6920a654e8bc81b602a39bb96216ba44ad7da53f.tar.gz
SERVER-16987 sh.getRecentMigrations shows aborted migration as success
(cherry picked from commit 40502abaac233ed0b27a9bf9612bd4df61811a68)
-rw-r--r--src/mongo/shell/utils_sh.js72
1 files changed, 57 insertions, 15 deletions
diff --git a/src/mongo/shell/utils_sh.js b/src/mongo/shell/utils_sh.js
index d9c05a3f06b..69ad01666b8 100644
--- a/src/mongo/shell/utils_sh.js
+++ b/src/mongo/shell/utils_sh.js
@@ -433,19 +433,61 @@ sh.getRecentFailedRounds = function() {
sh.getRecentMigrations = function() {
var configDB = db.getSiblingDB('config');
var yesterday = new Date( new Date() - 24 * 60 * 60 * 1000 );
- var result = []
- result = result.concat(configDB.changelog.aggregate( [
- { $match : { time : { $gt : yesterday }, what : "moveChunk.from", "details.errmsg" : {
- "$exists" : false } } },
- { $group : { _id: { msg: "$details.errmsg" }, count : { "$sum":1 } } },
- { $project : { _id : { $ifNull: [ "$_id.msg", "Success" ] }, count : "$count" } }
- ] ).toArray());
- result = result.concat(configDB.changelog.aggregate( [
- { $match : { time : { $gt : yesterday }, what : "moveChunk.from", "details.errmsg" : {
- "$exists" : true } } },
- { $group : { _id: { msg: "$details.errmsg", from : "$details.from", to: "$details.to" },
- count : { "$sum":1 } } },
- { $project : { _id : "$_id.msg" , from : "$_id.from", to : "$_id.to" , count : "$count" } }
- ] ).toArray());
+ var result = configDB.changelog.aggregate([
+ {
+ $match: {
+ time: { $gt: yesterday },
+ what: "moveChunk.from",
+ 'details.errmsg': { $exists: false },
+ 'details.note': 'success'
+ }
+ },
+ {
+ $group: {
+ _id: {
+ msg: "$details.errmsg"
+ },
+ count : { $sum: 1 }
+ }
+ },
+ {
+ $project: {
+ _id: { $ifNull: [ "$_id.msg", "Success" ] },
+ count: "$count"
+ }
+ }
+ ]).toArray();
+
+ result = result.concat(configDB.changelog.aggregate([
+ {
+ $match: {
+ time: { $gt: yesterday },
+ what : "moveChunk.from",
+ $or: [
+ { 'details.errmsg': { $exists: true }},
+ { 'details.note': { $ne: 'success' }}
+ ]
+ }
+ },
+ {
+ $group: {
+ _id: {
+ msg: "$details.errmsg",
+ from : "$details.from",
+ to: "$details.to"
+ },
+ count: { $sum: 1 }
+ }
+ },
+ {
+ $project: {
+ _id: { $ifNull: [ '$_id.msg', 'aborted' ]},
+ from: "$_id.from",
+ to: "$_id.to",
+ count: "$count"
+ }
+ }
+ ]).toArray());
+
return result;
-}
+};