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

Revert to long polling in the ServalClientHelper. Fixes #98. #143

Merged
merged 8 commits into from
Oct 2, 2023

Conversation

Enkidu93
Copy link
Collaborator

@Enkidu93 Enkidu93 commented Sep 26, 2023

I think this is the intended behavior. The only change I'm realizing I should possibly make is to make the Exception more specific (?).


This change is Reviewable

@johnml1135
Copy link
Collaborator

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

                revision++;
            }
            catch

The only thing we should be allowing this to continue on is timeouts - can you check the status code? Will the exception type be different? If it is another error, we should just rethrow.

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ddaspit and @Enkidu93)

@Enkidu93
Copy link
Collaborator Author

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

                revision++;
            }
            catch

The only thing we should be allowing this to continue on is timeouts - can you check the status code? Will the exception type be different? If it is another error, we should just rethrow.

Yep, my apologies. I can do that.

@johnml1135
Copy link
Collaborator

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, Enkidu93 (Eli C. Lowry) wrote…

Yep, my apologies. I can do that.

if (status_ == 408)
{
  string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);  throw new ServalApiException("The long polling request timed out.  Did you start the build?", status_, responseText_, headers_, null);
}

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Enkidu93)


tests/Serval.E2ETests/ServalClientHelper.cs line 130 at r2 (raw file):

                    break;
                }
                revision++;

We want to use the revision from the returned build model.

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Enkidu93)

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)

@Enkidu93
Copy link
Collaborator Author

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, johnml1135 (John Lambert) wrote…
if (status_ == 408)
{
  string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);  throw new ServalApiException("The long polling request timed out.  Did you start the build?", status_, responseText_, headers_, null);
}

Ultimately, this is what is thrown here. Although it's a bit janky, checking based on the message ought to be reliable. Is this OK with you, John?

@johnml1135
Copy link
Collaborator

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, Enkidu93 (Eli C. Lowry) wrote…

Ultimately, this is what is thrown here. Although it's a bit janky, checking based on the message ought to be reliable. Is this OK with you, John?

The ServalApiException has a StatusCode - can you check that instead?

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ddaspit)

@johnml1135
Copy link
Collaborator

tests/Serval.E2ETests/ServalClientHelper.cs line 129 at r4 (raw file):

                }
                revision = result.Revision;
            }

revision = result.Revision + 1; // look for the next revision, the current one

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Enkidu93)

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @johnml1135)


tests/Serval.E2ETests/ServalClientHelper.cs line 129 at r4 (raw file):

Previously, johnml1135 (John Lambert) wrote…

revision = result.Revision + 1; // look for the next revision, the current one

He is passing revision + 1 to GetBuildAsync.

@Enkidu93
Copy link
Collaborator Author

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, johnml1135 (John Lambert) wrote…

The ServalApiException has a StatusCode - can you check that instead?

I tried that initially, but that's not actually what gets thrown here. There are a few timeouts at play here. As I understand it, this timeout is actually the timeout thrown by the HTTP client itself. I am realizing though that this timeout is configured to only 10 seconds. Should we reconfigure it to be greater than the longpolltimeout option?

Copy link
Collaborator Author

@Enkidu93 Enkidu93 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @johnml1135)


tests/Serval.E2ETests/ServalClientHelper.cs line 129 at r4 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

He is passing revision + 1 to GetBuildAsync.

If it would be clearer to do otherwise, that's fine. But, of course, it has the same effect.

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @johnml1135)


tests/Serval.E2ETests/ServalClientHelper.cs line 129 at r4 (raw file):

Previously, Enkidu93 (Eli C. Lowry) wrote…

If it would be clearer to do otherwise, that's fine. But, of course, it has the same effect.

I don't have an opinion either way.

@johnml1135
Copy link
Collaborator

tests/Serval.E2ETests/ServalClientHelper.cs line 129 at r4 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

I don't have an opinion either way.

I didn't see it - it is clear enough.

@johnml1135
Copy link
Collaborator

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, Enkidu93 (Eli C. Lowry) wrote…

I tried that initially, but that's not actually what gets thrown here. There are a few timeouts at play here. As I understand it, this timeout is actually the timeout thrown by the HTTP client itself. I am realizing though that this timeout is configured to only 10 seconds. Should we reconfigure it to be greater than the longpolltimeout option?

Absolutely - we would want it to present itself as a proper message. We could also change it by having the long-poll timeout be under the http timeout, say 9 seconds? @ddaspit what do you think?

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)


tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, johnml1135 (John Lambert) wrote…

Absolutely - we would want it to present itself as a proper message. We could also change it by having the long-poll timeout be under the http timeout, say 9 seconds? @ddaspit what do you think?

Yes, we should set the request timeout for HttpClient to something higher than the long polling timeout. If we want a shorter timeout for other requests, we can control that using the cancellation token.

@Enkidu93
Copy link
Collaborator Author

tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Yes, we should set the request timeout for HttpClient to something higher than the long polling timeout. If we want a shorter timeout for other requests, we can control that using the cancellation token.

I went ahead and updated the timeout and the catch here. Question though: Is the Task.Delay even necessary at this point?

@johnml1135
Copy link
Collaborator

johnml1135 commented Sep 29, 2023 via email

@Enkidu93
Copy link
Collaborator Author

Task delay is still necessary if it increments very quickly. I have seen dozens if not, hundreds of requests per second on SMT training. There should be a max rate for updating. Get Outlook for iOShttps://aka.ms/o0ukef

________________________________ From: Eli C. Lowry @.> Sent: Friday, September 29, 2023 4:14:14 PM To: sillsdev/serval @.> Cc: John Lambert @.>; Mention @.> Subject: Re: [sillsdev/serval] Revert to long polling in the ServalClientHelper. Fixes #98. (PR #143) tests/Serval.E2ETests/ServalClientHelper.cs line 132 at r1https://reviewable.io/reviews/sillsdev/serval/143#-NfM2tV97d8QAMr7n14w:-NfXZn6q-aiQ4ZP8BcGh:b-8e2gn (raw file

): Previously, ddaspit (Damien Daspit) wrote… Yes, we should set the request timeout for HttpClient to something higher than the long polling timeout. If we want a shorter timeout for other requests, we can control that using the cancellation token. I went ahead and updated the timeout and the catch here. Question though: Is the Task.Delay even necessary at this point? — Reply to this email directly, view it on GitHub<#143 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADIY5NFKDXSE3H5VTBHG5DLX44TZNANCNFSM6AAAAAA5IJHRUI. You are receiving this because you were mentioned.Message ID: @.***>

OK, great! Can you approve this request? Or is there something left to do?

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ddaspit)

Copy link
Collaborator

@johnml1135 johnml1135 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ddaspit)

@johnml1135 johnml1135 merged commit bad1b9a into main Oct 2, 2023
1 of 2 checks passed
Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

I agree that we update the status too much for SMT training. Do we have an issue for that? We should throttle those updates internally.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Enkidu93 Enkidu93 deleted the revert_to_long_polling_#98 branch October 10, 2023 17:47
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

3 participants