@@ -1467,7 +1467,7 @@ class NamespaceFS {
1467
1467
} catch ( err ) {
1468
1468
retries -= 1 ;
1469
1469
const should_retry = native_fs_utils . should_retry_link_unlink ( is_gpfs , err ) ;
1470
- dbg . warn ( `NamespaceFS._move_to_dest_version retrying retries=${ retries } should_retry=${ should_retry } ` +
1470
+ dbg . warn ( `NamespaceFS._move_to_dest_version error: retries=${ retries } should_retry=${ should_retry } ` +
1471
1471
` new_ver_tmp_path=${ new_ver_tmp_path } latest_ver_path=${ latest_ver_path } ` , err ) ;
1472
1472
if ( ! should_retry || retries <= 0 ) throw err ;
1473
1473
await P . delay ( get_random_delay ( config . NSFS_RANDOM_DELAY_BASE , 0 , 50 ) ) ;
@@ -2696,7 +2696,7 @@ class NamespaceFS {
2696
2696
* 1. if version_id is not defined, it returns the key file
2697
2697
* 2. else,
2698
2698
* 2.1. check version format
2699
- * 2.2. check if latest version exists and it matches the versio_id parameter the latest version path returns
2699
+ * 2.2. check if the latest version exists and it matches the version_id parameter the latest version path returns
2700
2700
* 2.3. else, return the version path under .versions/
2701
2701
* @param {import('./nb').NativeFSContext } fs_context
2702
2702
* @param {{key: string, version_id?: string} } params
@@ -2746,6 +2746,11 @@ class NamespaceFS {
2746
2746
}
2747
2747
2748
2748
/**
2749
+ * _delete_single_object_versioned does the following -
2750
+ * if the deleted version is the latest - try to delete it from the latest version location
2751
+ * if the deleted version is in .versions/ - unlink the version
2752
+ * we call check_version_moved() in case of concurrent puts, the version might move to .versions/
2753
+ * if the version moved we will retry
2749
2754
* @param {nb.NativeFSContext } fs_context
2750
2755
* @param {string } key
2751
2756
* @param {string } version_id
@@ -2758,7 +2763,6 @@ class NamespaceFS {
2758
2763
* latest?: boolean;
2759
2764
* }>}
2760
2765
*/
2761
- // we can use this function when versioning is enabled or suspended
2762
2766
async _delete_single_object_versioned ( fs_context , key , version_id ) {
2763
2767
let retries = config . NSFS_RENAME_RETRIES ;
2764
2768
const is_gpfs = native_fs_utils . _is_gpfs ( fs_context ) ;
@@ -2778,15 +2782,15 @@ class NamespaceFS {
2778
2782
const bucket_tmp_dir_path = this . get_bucket_tmpdir_full_path ( ) ;
2779
2783
await native_fs_utils . safe_unlink ( fs_context , file_path , version_info ,
2780
2784
gpfs_options ?. delete_version , bucket_tmp_dir_path ) ;
2781
- await this . _check_version_moved ( fs_context , key , version_id , file_path ) ;
2785
+ await this . _check_version_moved ( fs_context , key , version_id ) ;
2782
2786
return { ...version_info , latest : true } ;
2783
2787
} else {
2784
2788
await native_fs_utils . unlink_ignore_enoent ( fs_context , file_path ) ;
2785
- await this . _check_version_moved ( fs_context , key , version_id , file_path ) ;
2789
+ await this . _check_version_moved ( fs_context , key , version_id ) ;
2786
2790
}
2787
2791
return version_info ;
2788
2792
} catch ( err ) {
2789
- dbg . warn ( `NamespaceFS._delete_single_object_versioned: retrying retries=${ retries } file_path=${ file_path } ` , err ) ;
2793
+ dbg . warn ( `NamespaceFS._delete_single_object_versioned error: retries=${ retries } file_path=${ file_path } ` , err ) ;
2790
2794
retries -= 1 ;
2791
2795
// there are a few concurrency scenarios that might happen we should retry for -
2792
2796
// 1. the version id is the latest, concurrent put will might move the version id from being the latest to .versions/ -
@@ -2899,14 +2903,14 @@ class NamespaceFS {
2899
2903
max_past_ver_info , bucket_tmp_dir_path ) ;
2900
2904
break ;
2901
2905
} catch ( err ) {
2906
+ dbg . warn ( `NamespaceFS: _promote_version_to_latest failed error: retries=${ retries } ` , err ) ;
2902
2907
retries -= 1 ;
2903
2908
if ( retries <= 0 ) throw err ;
2904
2909
if ( ! native_fs_utils . _is_gpfs ( fs_context ) && err . code === 'EEXIST' ) {
2905
2910
dbg . warn ( 'Namespace_fs._delete_version_id: latest version exist - skipping' ) ;
2906
2911
return ;
2907
2912
}
2908
2913
if ( err . code !== 'ENOENT' ) throw err ;
2909
- dbg . warn ( `NamespaceFS: _promote_version_to_latest failed retries=${ retries } ` , err ) ;
2910
2914
await P . delay ( get_random_delay ( config . NSFS_RANDOM_DELAY_BASE , 0 , 50 ) ) ;
2911
2915
}
2912
2916
}
@@ -3003,9 +3007,9 @@ class NamespaceFS {
3003
3007
gpfs_options ?. delete_version , bucket_tmp_dir_path ) ;
3004
3008
break ;
3005
3009
} catch ( err ) {
3010
+ dbg . warn ( `NamespaceFS._delete_null_version_from_versions_directory error: retries=${ retries } null_versioned_path=${ null_versioned_path } ` , err ) ;
3006
3011
retries -= 1 ;
3007
3012
if ( retries <= 0 || ! native_fs_utils . should_retry_link_unlink ( is_gpfs , err ) ) throw err ;
3008
- dbg . warn ( `NamespaceFS._delete_null_version_from_versions_directory Retrying retries=${ retries } null_versioned_path=${ null_versioned_path } ` , err ) ;
3009
3013
await P . delay ( get_random_delay ( config . NSFS_RANDOM_DELAY_BASE , 0 , 50 ) ) ;
3010
3014
} finally {
3011
3015
if ( gpfs_options ) await this . _close_files_gpfs ( fs_context , gpfs_options . delete_version , undefined , true ) ;
@@ -3039,13 +3043,13 @@ class NamespaceFS {
3039
3043
await nb_native ( ) . fs . rename ( fs_context , upload_params . upload_path , file_path ) ;
3040
3044
return delete_marker_version_id ;
3041
3045
} catch ( err ) {
3046
+ dbg . warn ( `NamespaceFS: _create_delete_marker failed error: retries=${ retries } ` , err ) ;
3042
3047
retries -= 1 ;
3043
3048
if ( retries <= 0 ) throw err ;
3044
3049
if ( err . code === 'EEXIST' ) {
3045
3050
dbg . warn ( `NamespaceFS: _create_delete_marker already exists, success` , err ) ;
3046
3051
return delete_marker_version_id ;
3047
3052
}
3048
- dbg . warn ( `NamespaceFS: _create_delete_marker failed retries=${ retries } ` , err ) ;
3049
3053
await P . delay ( get_random_delay ( config . NSFS_RANDOM_DELAY_BASE , 0 , 50 ) ) ;
3050
3054
} finally {
3051
3055
if ( upload_params ) await this . complete_object_upload_finally ( undefined , undefined , upload_params . target_file , fs_context ) ;
@@ -3159,18 +3163,18 @@ class NamespaceFS {
3159
3163
3160
3164
/**
3161
3165
* _check_version_moved recieves key and version_id and checks if the version still exists in one of the optional locations
3162
- * latest version location or .versions
3166
+ * latest version location or .versions/ directory
3163
3167
* @param {import('./nb').NativeFSContext } fs_context
3164
3168
* @param {string } key
3165
3169
* @param {string } version_id
3166
3170
*/
3167
3171
async _check_version_moved ( fs_context , key , version_id ) {
3168
3172
const latest_version_path = this . _get_file_path ( { key } ) ;
3169
- const verisoned_path = this . _get_version_path ( key , version_id ) ;
3170
- const verisoned_path_info = await this . _get_version_info ( fs_context , verisoned_path ) ;
3171
- if ( verisoned_path_info ) throw error_utils . new_error_code ( 'VERSION_MOVED' , `version file moved from latest ${ latest_version_path } to .versions/ ${ verisoned_path } , retrying` ) ;
3173
+ const versioned_path = this . _get_version_path ( key , version_id ) ;
3174
+ const versioned_path_info = await this . _get_version_info ( fs_context , versioned_path ) ;
3175
+ if ( versioned_path_info ) throw error_utils . new_error_code ( 'VERSION_MOVED' , `version file moved from latest ${ latest_version_path } to .versions/ ${ versioned_path } , retrying` ) ;
3172
3176
const latest_ver_info = await this . _get_version_info ( fs_context , latest_version_path ) ;
3173
- if ( latest_ver_info && latest_ver_info . version_id_str === version_id ) throw error_utils . new_error_code ( 'VERSION_MOVED' , `version file moved from .versions/ ${ verisoned_path } to latest ${ latest_version_path } , retrying` ) ;
3177
+ if ( latest_ver_info && latest_ver_info . version_id_str === version_id ) throw error_utils . new_error_code ( 'VERSION_MOVED' , `version file moved from .versions/ ${ versioned_path } to latest ${ latest_version_path } , retrying` ) ;
3174
3178
}
3175
3179
3176
3180
async _throw_if_storage_class_not_supported ( storage_class ) {
0 commit comments