Skip to content

Conversation

@timvaillancourt
Copy link
Collaborator

@timvaillancourt timvaillancourt commented May 31, 2022

Resolves issue: #1130

Description

This PR passes a context.Context to the net/http client in go/logic/throttler.go to address the lack of a timeout in the HTTP-based throttler. Also the User-Agent header is now set to gh-ost/VERSION (eg gh-ost/1.1.4 for version 1.1.4) instead of the net/http default

This fix will prevent HTTP-throttler blocking infinitely when the HTTP throttler source is slow to respond

This PR also enables the noctx linter in CI jobs so we can catch code that could use a context in the future

Also the previously-hardcoded (100ms) check interval for the HTTP-throttler was moved to the command-line flag --throttle-http-interval-millis (default 100). The timeout value for the HTTP check is controlled with --throttle-http-timeout-millis (default 1000)

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

@timvaillancourt timvaillancourt assigned rashiq and ghost and unassigned rashiq and ghost May 31, 2022
@timvaillancourt timvaillancourt requested review from a user and rashiq May 31, 2022 21:50
@timvaillancourt timvaillancourt self-assigned this May 31, 2022
@timvaillancourt timvaillancourt linked an issue May 31, 2022 that may be closed by this pull request
@timvaillancourt timvaillancourt added this to the v1.1.5 milestone Jun 2, 2022
@timvaillancourt timvaillancourt merged commit 0918bab into github:master Jul 6, 2022
@timvaillancourt timvaillancourt deleted the throttle-http-context branch July 6, 2022 21:56
ghost pushed a commit that referenced this pull request Jul 7, 2022
* Add context/timeout to HTTP throttle check

* Dont run `.GetThrottleHTTPInterval()` on every loop

* Update help message

* Var rename

* 2022

* Add timeout flag

* Add unix/tcp server commands, use ParseInt() for string->int64

* Var rename

* Re-check http timeout on every loop iteration

* Remove stale comment

* Make throttle interval idempotent

* var rename

* Usage grammar

* Make http timeout idempotent too

* Parse time.Duration once

* Move timeout to NewThrottler

* Help update

* Set User-Agent header

* Re-add newline

Co-authored-by: dm-2 <45519614+dm-2@users.noreply.github.com>
@ghost ghost mentioned this pull request Jul 7, 2022
ghost pushed a commit that referenced this pull request Jul 7, 2022
* Add context/timeout to HTTP throttle check

* Dont run `.GetThrottleHTTPInterval()` on every loop

* Update help message

* Var rename

* 2022

* Add timeout flag

* Add unix/tcp server commands, use ParseInt() for string->int64

* Var rename

* Re-check http timeout on every loop iteration

* Remove stale comment

* Make throttle interval idempotent

* var rename

* Usage grammar

* Make http timeout idempotent too

* Parse time.Duration once

* Move timeout to NewThrottler

* Help update

* Set User-Agent header

* Re-add newline

Co-authored-by: dm-2 <45519614+dm-2@users.noreply.github.com>
RainbowDashy pushed a commit to RainbowDashy/gh-ost that referenced this pull request Jul 11, 2022
* Add context/timeout to HTTP throttle check

* Dont run `.GetThrottleHTTPInterval()` on every loop

* Update help message

* Var rename

* 2022

* Add timeout flag

* Add unix/tcp server commands, use ParseInt() for string->int64

* Var rename

* Re-check http timeout on every loop iteration

* Remove stale comment

* Make throttle interval idempotent

* var rename

* Usage grammar

* Make http timeout idempotent too

* Parse time.Duration once

* Move timeout to NewThrottler

* Help update

* Set User-Agent header

* Re-add newline

Co-authored-by: dm-2 <45519614+dm-2@users.noreply.github.com>
timvaillancourt added a commit to timvaillancourt/gh-ost that referenced this pull request Aug 10, 2022
timvaillancourt added a commit that referenced this pull request Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP throttler has no timeout

2 participants