Skip to content

Commit 15eab01

Browse files
authored
Merge pull request #8485 from nadavMiz/delete_version_concurrency
NSFS | GPFS | versioning | fix delete version concurrency issues
2 parents 348fe72 + 3a05283 commit 15eab01

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/sdk/namespace_fs.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ class NamespaceFS {
963963
dbg.warn(`NamespaceFS.read_object_md: retrying retries=${retries} file_path=${file_path}`, err);
964964
retries -= 1;
965965
if (retries <= 0 || !native_fs_utils.should_retry_link_unlink(is_gpfs, err)) throw err;
966+
await P.delay(get_random_delay(config.NSFS_RANDOM_DELAY_BASE, 0, 50));
966967
}
967968
}
968969
this._throw_if_delete_marker(stat, params);
@@ -1037,6 +1038,7 @@ class NamespaceFS {
10371038
{bucket_path: this.bucket_path, object_name: params.key}, err);
10381039
throw err;
10391040
}
1041+
await P.delay(get_random_delay(config.NSFS_RANDOM_DELAY_BASE, 0, 50));
10401042
}
10411043
}
10421044
this._throw_if_delete_marker(stat, params);
@@ -2847,6 +2849,13 @@ class NamespaceFS {
28472849
const deleted_latest = file_path === latest_version_path;
28482850
if (deleted_latest) {
28492851
gpfs_options = await this._open_files_gpfs(fs_context, file_path, undefined, undefined, undefined, undefined, true);
2852+
if (gpfs_options) {
2853+
const src_stat = await gpfs_options.delete_version.src_file.stat(fs_context);
2854+
if (this._is_mismatch_version_id(src_stat, version_id)) {
2855+
dbg.warn('NamespaceFS._delete_single_object_versioned mismatch version_id', file_path, version_id, this._get_version_id_by_xattr(src_stat));
2856+
throw error_utils.new_error_code('MISMATCH_VERSION', 'file version does not match the version we asked for');
2857+
}
2858+
}
28502859
const bucket_tmp_dir_path = this.get_bucket_tmpdir_full_path();
28512860
await native_fs_utils.safe_unlink(fs_context, file_path, version_info,
28522861
gpfs_options?.delete_version, bucket_tmp_dir_path);
@@ -3007,15 +3016,17 @@ class NamespaceFS {
30073016
let latest_ver_info;
30083017
for (;;) {
30093018
try {
3010-
// get latest version_id if exists
3019+
// TODO get latest version from file in POSIX like in GPFS path
30113020
latest_ver_info = await this._get_version_info(fs_context, latest_ver_path);
3012-
const versioned_path = latest_ver_info && this._get_version_path(params.key, latest_ver_info.version_id_str);
3013-
const versioned_info = latest_ver_info && await this._get_version_info(fs_context, versioned_path);
3014-
3015-
dbg.log1('Namespace_fs._delete_latest_version:', latest_ver_info, versioned_path, versioned_info);
3021+
dbg.log1('Namespace_fs._delete_latest_version:', latest_ver_info);
30163022
if (latest_ver_info) {
3023+
if (is_gpfs) {
30173024
gpfs_options = await this._open_files_gpfs(fs_context, latest_ver_path, undefined, undefined, undefined,
3018-
undefined, true, versioned_info);
3025+
undefined, true);
3026+
const latest_fd = gpfs_options?.move_to_dst?.dst_file;
3027+
latest_ver_info = latest_fd && await this._get_version_info(fs_context, undefined, latest_fd);
3028+
}
3029+
const versioned_path = latest_ver_info && this._get_version_path(params.key, latest_ver_info.version_id_str);
30193030

30203031
const suspended_and_latest_is_not_null = this._is_versioning_suspended() &&
30213032
latest_ver_info.version_id_str !== NULL_VERSION_ID;
@@ -3172,7 +3183,7 @@ class NamespaceFS {
31723183
let dir_file;
31733184
let versioned_file;
31743185
try {
3175-
// open /versions/key_ver file if exists
3186+
// open /versions/key_ver file if exists. TODO is versioned_file needed
31763187
versioned_file = versioned_info && await native_fs_utils.open_file(fs_context, this.bucket_path, versioned_info.path, 'r');
31773188

31783189
// open files for deletion flow

0 commit comments

Comments
 (0)