Skip to content

Commit

Permalink
Infra: introduce retry func warpper
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 12, 2024
1 parent bb1efa5 commit 99bb24f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tosfs/stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
"500", # INTERNAL_SERVER_ERROR
}

TOS_SERVER_NOT_RETRYABLE_CONFLICT_ERROR_CODES = {
"0026-00000013", # DELETE_NON_EMPTY_DIR
"0026-00000020", # LOCATED_UNDER_A_FILE
"0026-00000021", # COPY_BETWEEN_DIR_AND_FILE
"0026-00000022", # PATH_LOCK_CONFLICT
"0026-00000025", # RENAME_TO_AN_EXISTED_DIR
"0026-00000026", # RENAME_TO_SUB_DIR
"0026-00000027", # RENAME_BETWEEN_DIR_AND_FILE
"0017-00000208", # APPEND_OFFSET_NOT_MATCHED
"0017-00000209", # APPEND_NOT_APPENDABLE
}

TOS_CLIENT_RETRYABLE_EXCEPTIONS = {
HTTPError,
requests.ConnectionError,
Expand Down Expand Up @@ -101,6 +113,9 @@ def _is_retryable_tos_server_exception(e: TosError) -> bool:
return (
isinstance(e, TosServerError)
and e.status_code in TOS_SERVER_RETRYABLE_STATUS_CODES
# exclude some special error code under 409(conflict) status code
# let it fast fail
and e.code not in TOS_SERVER_NOT_RETRYABLE_CONFLICT_ERROR_CODES
)


Expand Down

0 comments on commit 99bb24f

Please sign in to comment.