Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
significantly reduce false negative rate in copy operation; better gc…
Browse files Browse the repository at this point in the history
… for

failed copy operation

Change-Id: Iac2e8bbfac6a7ee639df27ec5dc6fcbaead08d17
  • Loading branch information
SonicWang committed Nov 1, 2011
1 parent 2c7b6f4 commit a5f1831
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/fs/blob_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var MAX_LIST_LENGTH = 1000; //max number of objects to list
var base64_char_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var TEMP_FOLDER = "~tmp";
var GC_FOLDER = "~gc";
var MAX_COPY_RETRY = 3;

var gc_hash = {}; //for caching gc info;

Expand Down Expand Up @@ -524,7 +525,7 @@ FS_blob.prototype.object_delete_meta = function (bucket_name, filename, callback
});
};

FS_blob.prototype.object_copy = function (bucket_name,filename,source_bucket,source_file,options, metadata, callback,fb)
FS_blob.prototype.object_copy = function (bucket_name,filename,source_bucket,source_file,options, metadata, callback,fb, retry_cnt)
{
var resp = {};
//step 1 check bucket existence
Expand Down Expand Up @@ -578,6 +579,11 @@ FS_blob.prototype.object_copy = function (bucket_name,filename,source_bucket,sou
//read src meta here
fs.readFile(src_meta_path, function(err,data) {
if (err) {
if (!retry_cnt) retry_cnt = 0;
if (retry_cnt < MAX_COPY_RETRY) { //reduce the false negative rate
setTimeout(function(fb1) { fb1.object_copy(bucket_name, filename, source_bucket, source_file, options, metadata, callback,fb1, !retry_cnt?1:retry_cnt+1); }, Math.floor(Math.random()*1000) + 100,fb);
return;
}
error_msg(404,"NoSuchFile",err,resp);
callback(resp.resp_code, resp.resp_header, resp.resp_body, null);
return;
Expand Down Expand Up @@ -653,6 +659,12 @@ FS_blob.prototype.object_copy = function (bucket_name,filename,source_bucket,sou
}
fs.link(src_path+"/"+obj.vblob_file_path, c_path+"/"+dest_obj.vblob_file_path, function(err) {
if (err) {
remove_uploaded_file(temp_path);
if (!retry_cnt) retry_cnt = 0;
if (retry_cnt < MAX_COPY_RETRY) { //reduce the false negative rate
setTimeout(function(fb1) { fb1.object_copy(bucket_name, filename, source_bucket, source_file, options, metadata, callback,fb1, !retry_cnt?1:retry_cnt+1); }, Math.floor(Math.random()*1000) + 100,fb);
return;
}
error_msg(500,"InternalError",""+err,resp);
callback(resp.resp_code, resp.resp_header, resp.resp_body, null);
return;
Expand Down

0 comments on commit a5f1831

Please sign in to comment.