Compare commits
4 Commits
developmen
...
test/repai
Author | SHA1 | Date |
---|---|---|
philipyoo | aa95b72aa3 | |
philipyoo | 2a1a25a3f3 | |
philipyoo | 97fa83fc62 | |
philipyoo | 5df8e304c6 |
|
@ -538,7 +538,13 @@ class MongoClientInterface {
|
||||||
_id: objName,
|
_id: objName,
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
_id: objName, value: mst,
|
$min: {
|
||||||
|
'value.versionId': params.versionId,
|
||||||
|
},
|
||||||
|
$setOnInsert: {
|
||||||
|
'_id': objName,
|
||||||
|
'value.isPHD': true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
upsert: true,
|
upsert: true,
|
||||||
},
|
},
|
||||||
|
@ -551,6 +557,11 @@ class MongoClientInterface {
|
||||||
});
|
});
|
||||||
return cb(errors.InternalError);
|
return cb(errors.InternalError);
|
||||||
}
|
}
|
||||||
|
// Attempt to repair master
|
||||||
|
setTimeout(() => {
|
||||||
|
this.asyncRepair(c, bucketName, objName, mst, log,
|
||||||
|
{ action: 'put' });
|
||||||
|
}, ASYNC_REPAIR_TIMEOUT);
|
||||||
return cb(null, `{"versionId": "${objVal.versionId}"}`);
|
return cb(null, `{"versionId": "${objVal.versionId}"}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -696,13 +707,26 @@ class MongoClientInterface {
|
||||||
* Get the latest version and repair. The process is safe because
|
* Get the latest version and repair. The process is safe because
|
||||||
* we never replace a non-PHD master
|
* we never replace a non-PHD master
|
||||||
*/
|
*/
|
||||||
asyncRepair(c, bucketName, objName, mst, log) {
|
asyncRepair(c, bucketName, objName, mst, log, options) {
|
||||||
this.getLatestVersion(c, objName, log, (err, value) => {
|
this.getLatestVersion(c, objName, log, (err, value) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('async-repair: getting latest version',
|
log.error('async-repair: getting latest version',
|
||||||
{ error: err.message });
|
{ error: err.message });
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
// if a PHD was created on put, compare latest version with
|
||||||
|
// the version id saved on PHD
|
||||||
|
if (options && options.action === 'put') {
|
||||||
|
console.log('\n==== IN ASYNC REPAIR ====')
|
||||||
|
console.log('RECEIVED ACTION PUT')
|
||||||
|
console.log(`${value.versionId} !== ${mst.versionId}`)
|
||||||
|
// if version id does not match, PHD has been replaced and
|
||||||
|
// we should ignore this repair
|
||||||
|
if (value.versionId !== mst.versionId) {
|
||||||
|
console.log('VERSION ID DOES NOT MATCH, IGNORE THIS REPAIR')
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.repair(c, bucketName, objName, value, mst, log, err => {
|
this.repair(c, bucketName, objName, value, mst, log, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('async-repair failed', { error: err.message });
|
log.error('async-repair failed', { error: err.message });
|
||||||
|
|
Loading…
Reference in New Issue