Skip to content

NSFS | GPFS | fix put object over null version in suspended mode #8386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/sdk/namespace_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1430,9 +1430,11 @@ class NamespaceFS {

if (this._is_versioning_suspended()) {
if (latest_ver_info?.version_id_str === NULL_VERSION_ID) {
dbg.log1('NamespaceFS._move_to_dest_version suspended: version ID of the latest version is null - the file will be unlinked');
await native_fs_utils.safe_unlink(fs_context, latest_ver_path, latest_ver_info,
gpfs_options?.delete_version, bucket_tmp_dir_path);
//on GPFS safe_move overrides the latest object so no need to unlink
if (!is_gpfs) {
dbg.log1('NamespaceFS._move_to_dest_version suspended: version ID of the latest version is null - the file will be unlinked');
await native_fs_utils.safe_unlink(fs_context, latest_ver_path, latest_ver_info, undefined, bucket_tmp_dir_path);
}
} else {
// remove a version (or delete marker) with null version ID from .versions/ (if exists)
await this._delete_null_version_from_versions_directory(key, fs_context);
Expand Down Expand Up @@ -2981,9 +2983,9 @@ class NamespaceFS {
undefined;
const bucket_tmp_dir_path = this.get_bucket_tmpdir_full_path();
await native_fs_utils.safe_unlink(fs_context, null_versioned_path, null_versioned_path_info,
gpfs_options, bucket_tmp_dir_path);
gpfs_options?.delete_version, bucket_tmp_dir_path);

if (gpfs_options) await this._close_files_gpfs(fs_context, gpfs_options.delete_version, undefined, true);
if (gpfs_options) await this._close_files_gpfs(fs_context, gpfs_options?.delete_version, undefined, true);
}
break;
} catch (err) {
Expand Down
10 changes: 10 additions & 0 deletions src/test/unit_tests/test_nsfs_versioning_gpfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ mocha.describe('namespace_fs gpfs- versioning', async function() {
assert.ok(delete_objects_res.created_version_id !== undefined);
});

mocha.it('Suspended mode - add object null version twice', async function() {
await ns_obj.set_bucket_versioning('SUSPENDED', dummy_object_sdk);
const key3 = 'key3';
const put_res = await put_object(dummy_object_sdk, ns_obj, gpfs_bucket, key3);
assert.equal(put_res.version_id, 'null');
//issue #8379, overwriting null value should not fail on GPFS
const put_res2 = await put_object(dummy_object_sdk, ns_obj, gpfs_bucket, key3);
assert.equal(put_res2.version_id, 'null');
});

});

async function put_object(dummy_object_sdk, ns, bucket, key) {
Expand Down