1
0
Fork 0

Fix drop and add reporting in agency current

This commit is contained in:
Andreas Streichardt 2017-01-26 13:58:34 +01:00
parent 30baf07652
commit 2476cf7146
2 changed files with 60 additions and 1 deletions

View File

@ -59,6 +59,9 @@ var isEqual = function(object, other) {
}
if (Array.isArray(object)) {
if (object.length !== other.length) {
return false;
}
return object.every((value, index) => {
return isEqual(value, other[index]);
});
@ -674,6 +677,7 @@ function createIndexes(collection, plannedIndexes) {
return localId(plannedIndex) === index.id;
}).length === 0;
});
return indexesToDelete.reduce((errors, index) => {
console.debug("dropping index '%s/%s': %s",
collection._dbName,
@ -1010,8 +1014,8 @@ function updateCurrentForCollections(localErrors, currentCollections) {
let shardInfo = localCollections[shard];
if (shardInfo.isLeader) {
let localCollectionInfo = assembleLocalCollectionInfo(shardInfo, localErrors[shard] || {});
let currentCollectionInfo = fetchKey(currentCollections, database, shardInfo.planId, shard);
if (!isEqual(localCollectionInfo, currentCollectionInfo)) {
trx[curCollections + database + '/' + shardInfo.planId + '/' + shardInfo.name] = {
op: 'set',

View File

@ -1118,5 +1118,60 @@ describe('Cluster sync', function() {
.that.has.deep.property('new.indexes.1.error')
.equals(true);
});
it('should report deleted indexes', function() {
let current = {
testung: {
888111: {
testi : { "error" : false, "errorMessage" : "", "errorNum" : 0, "indexes" : [ { "id" : "0", "type" : "primary", "fields" : [ "_key" ], "selectivityEstimate" : 1, "unique" : true, "sparse" : false },
{
"fields": [
"test"
],
"id": "testi",
"selectivityEstimate": 1,
"sparse": false,
"type": "hash",
"unique": false
}
], "servers" : [ "repltest" ] }
},
}
};
let props = { planId: '888111' };
let collection = db._create('testi', props);
collection.assumeLeadership();
let result = cluster.updateCurrentForCollections({}, current);
expect(result).to.be.an('object');
expect(Object.keys(result)).to.have.lengthOf(1);
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')
.that.have.property('op', 'set');
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')
.that.has.deep.property('new.indexes')
.that.has.lengthOf(1);
});
it('should report added indexes', function() {
let current = {
testung: {
888111: {
testi : { "error" : false, "errorMessage" : "", "errorNum" : 0, "indexes" : [ { "id" : "0", "type" : "primary", "fields" : [ "_key" ], "selectivityEstimate" : 1, "unique" : true, "sparse" : false },
], "servers" : [ "repltest" ] }
},
}
};
let props = { planId: '888111' };
let collection = db._create('testi', props);
collection.assumeLeadership();
collection.ensureIndex({type: "hash", fields: ["test"]});
let result = cluster.updateCurrentForCollections({}, current);
expect(result).to.be.an('object');
expect(Object.keys(result)).to.have.lengthOf(1);
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')
.that.have.property('op', 'set');
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')
.that.has.deep.property('new.indexes')
.that.has.lengthOf(2);
});
});
});