Skip to content
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

Add exception handling for SMBFileSystem init connection errors #1650

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

GalLadislav
Copy link
Contributor

@GalLadislav GalLadislav commented Jul 20, 2024

Related to #1571

This PR implements exception handling for SMBFileSystem._connect() which brings changes to the current implementation:

  • reraise exceptions related to authentication issues
  • reraise ValueError exceptions related to configuration
  • retry on connection issues raised by socket
  • retry all other exceptions
  • distinguished attempts and retries, where always one attempt to register a session is made

Retrying all other exceptions could be dropped in the future once all exceptions suited for retry are identified. Until then, we should probably not affect current behavior as much as we should.

Other feature proposed in this PR is raising latest exception after all retries are exhausted. This will at least inform a user about excepted issue. (related question is whether to implement ExceptionGroup to inform about all exceptions)

Additionally, an implementation for exponential wait time growth from 0 to requested time (included) is added.
The wait time is calculated using exponential function. For factor=1 all wait times will be equal to register_session_retry_wait. For any number of retries, the last wait time will be equal to register_session_retry_wait and for retries>1 the first wait time will be equal to register_session_retry_wait / factor.
By default a factor is made 10 as most optimal (quick first attempts)

@GalLadislav GalLadislav marked this pull request as draft July 20, 2024 12:31
retried_errors.append(exc)

if retry < self.register_session_retries - 1:
time.sleep(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well make the retry time configurable and ideally exponential, base * factor**retry

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is great idea. Should the exponential option be also configurable? To avoid confusing a user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to make the max time equal to the wait time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting idea, but not the way around it is is other implementations (example). At least, then I would call it "max_wait_time", but probably better to have "base_wait_time" and backoff factor.

@GalLadislav GalLadislav marked this pull request as ready for review July 20, 2024 21:06
@GalLadislav GalLadislav marked this pull request as draft July 20, 2024 21:08
@GalLadislav GalLadislav marked this pull request as ready for review July 20, 2024 21:16
@martindurant martindurant merged commit 3ff5fca into fsspec:master Jul 24, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants