Skip to content

Commit

Permalink
fix(tableau): retry if 502 error code (#12233)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomezvillamor authored Dec 27, 2024
1 parent 3ca8d09 commit 29e4528
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions metadata-ingestion/src/datahub/ingestion/source/tableau/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@
except ImportError:
REAUTHENTICATE_ERRORS = (NonXMLResponseError,)

RETRIABLE_ERROR_CODES = [
408, # Request Timeout
429, # Too Many Requests
500, # Internal Server Error
502, # Bad Gateway
503, # Service Unavailable
504, # Gateway Timeout
]

logger: logging.Logger = logging.getLogger(__name__)

# Replace / with |
Expand Down Expand Up @@ -287,7 +296,7 @@ def make_tableau_client(self, site: str) -> Server:
max_retries=Retry(
total=self.max_retries,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504],
status_forcelist=RETRIABLE_ERROR_CODES,
)
)
server._session.mount("http://", adapter)
Expand Down Expand Up @@ -1212,9 +1221,11 @@ def get_connection_object_page(

except InternalServerError as ise:
# In some cases Tableau Server returns 504 error, which is a timeout error, so it worths to retry.
if ise.code == 504:
# Extended with other retryable errors.
if ise.code in RETRIABLE_ERROR_CODES:
if retries_remaining <= 0:
raise ise
logger.info(f"Retrying query due to error {ise.code}")
return self.get_connection_object_page(
query=query,
connection_type=connection_type,
Expand Down

0 comments on commit 29e4528

Please sign in to comment.