Skip to content

Commit 24bd9c4

Browse files
committed
NSFS | GPFS | fix put object over null version in suspended mode
Signed-off-by: nadav mizrahi <nadav.mizrahi16@gmail.com>
1 parent 8860143 commit 24bd9c4

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/sdk/namespace_fs.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,9 +1430,11 @@ class NamespaceFS {
14301430

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

2986-
if (gpfs_options) await this._close_files_gpfs(fs_context, gpfs_options.delete_version, undefined, true);
2988+
if (gpfs_options) await this._close_files_gpfs(fs_context, gpfs_options?.delete_version, undefined, true);
29872989
}
29882990
break;
29892991
} catch (err) {

src/test/unit_tests/test_nsfs_versioning_gpfs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ mocha.describe('namespace_fs gpfs- versioning', async function() {
218218
assert.ok(delete_objects_res.created_version_id !== undefined);
219219
});
220220

221+
mocha.it('Suspended mode - add object null version twice', async function() {
222+
await ns_obj.set_bucket_versioning('SUSPENDED', dummy_object_sdk);
223+
const key3 = 'key3';
224+
const put_res = await put_object(dummy_object_sdk, ns_obj, gpfs_bucket, key3);
225+
assert.equal(put_res.version_id, 'null');
226+
//issue #8379, overwriting null value should not fail on GPFS
227+
const put_res2 = await put_object(dummy_object_sdk, ns_obj, gpfs_bucket, key3);
228+
assert.equal(put_res2.version_id, 'null');
229+
});
230+
221231
});
222232

223233
async function put_object(dummy_object_sdk, ns, bucket, key) {

0 commit comments

Comments
 (0)