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

Fix Arc unwrap function not respecting timeout #4067

Merged
merged 3 commits into from
Apr 18, 2024
Merged

Conversation

timvisee
Copy link
Member

It appears the try_unwrap_with_timeout function did not respect the specified timeout.

I've changed the implementation to actually check it each iteration. To keep the implementation simple the timeout has a minimum resolution of spin.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Co-authored-by: Roman Titov <ffuugoo@users.noreply.github.com>
Comment on lines 62 to 71
match Arc::try_unwrap(arc) {
inner @ Ok(_) => return inner,
Ok(inner) => return Ok(inner),
Err(inner) => {
arc = inner;
if start.elapsed() >= timeout {
return Err(arc);
}
sleep(spin);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just came up with a better (?) suggestion:

        arc = match Arc::try_unwrap(arc) {
            Ok(unwrapped) => return Ok(unwrapped),
            Err(arc) => arc,
        };

        if start.elapsed() >= timeout {
            return Err(arc);
        }

        sleep(spin);

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, better indeed

@timvisee timvisee merged commit 60998e9 into dev Apr 18, 2024
17 checks passed
@timvisee timvisee deleted the fix-try-arc-unwrap branch April 18, 2024 14:45
timvisee added a commit that referenced this pull request Apr 22, 2024
* Fix Arc unwrap function not respecting timeout

* Update lib/collection/src/collection_manager/holders/segment_holder.rs

Co-authored-by: Roman Titov <ffuugoo@users.noreply.github.com>

* Cleanup `try_unwrap_with_timeout`

---------

Co-authored-by: Roman Titov <ffuugoo@users.noreply.github.com>
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.

None yet

2 participants