Compare commits

...

4 Commits

Author SHA1 Message Date
philipyoo aa95b72aa3 use setOnInsert and min 2019-06-06 16:54:46 -07:00
philipyoo 2a1a25a3f3 test max field 2019-06-06 11:38:10 -07:00
philipyoo 97fa83fc62 add logs 2019-06-06 10:12:38 -07:00
philipyoo 5df8e304c6 bf: ZENKO-1865 repair PHD master for puts
For putObjectVerCase4, we create an isPHD master on each
versioned put. Add a repair process to replace master isPHD
with the correct masters' value.
2019-06-06 10:08:14 -07:00
1 changed files with 26 additions and 2 deletions

View File

@ -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 });