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 context/timeout to HTTP throttle check #1131

Merged
merged 21 commits into from
Jul 6, 2022

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 dm-2 and unassigned rashiq and dm-2 May 31, 2022
@timvaillancourt timvaillancourt requested review from dm-2 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
dm-2 added 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 <[email protected]>
@dm-2 dm-2 mentioned this pull request Jul 7, 2022
dm-2 added 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 <[email protected]>
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 <[email protected]>
d-bytebase pushed a commit to bytebase/gh-ost that referenced this pull request Jul 13, 2022
* Merge pull request github#1143 from github/codeql-run-on-prs

Run CodeQL analysis on PRs

* Merge pull request github#1141 from shaohk/fix-two-phase-commit-lost-data_v2

fix(lost data in mysql two-phase commit): lost data in mysql two-phas…

* compound pk tests (github#387)

* compound pk tests

* more details in failure diff

* more elaborate test; the pk-ts one consistently fails

* Fix merge conflict

Co-authored-by: Shlomi Noach <[email protected]>
Co-authored-by: Tim Vaillancourt <[email protected]>
Co-authored-by: Tim Vaillancourt <[email protected]>

* Use `switch` statements for readability, simplify `.NewGoMySQLReader()` (github#1135)

* Use `switch` statements for readability

* Simplify initBinlogReader()

* Add context/timeout to HTTP throttle check (github#1131)

* 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 <[email protected]>

* Default to `go1.17.11` (github#1136)

* Default to go1.17.11

* `go mod vendor`

Co-authored-by: dm-2 <[email protected]>

* Cancel any row count queries before attempting to cut over (github#846)

* Cancel any row count queries before attempting to cut over

Closes github#830. Switches from using `QueryRow` to `QueryRowContext`, and
stores a context.CancelFunc in the migration context, which is called to
halt any running row count query before beginning the cut over.

* Make it threadsafe

* Kill the count query on the database side as well

* Explicitly grab a connection to run the count, store its connection id
* When the query context is canceled, run a `KILL QUERY ?` on that connection id

* Rewrite these to use the threadsafe functions, stop exporting the cancel func

* Update logger

* Update logger

Co-authored-by: Tim Vaillancourt <[email protected]>
Co-authored-by: Tim Vaillancourt <[email protected]>
Co-authored-by: dm-2 <[email protected]>

Co-authored-by: dm-2 <[email protected]>
Co-authored-by: Shlomi Noach <[email protected]>
Co-authored-by: Shlomi Noach <[email protected]>
Co-authored-by: Tim Vaillancourt <[email protected]>
Co-authored-by: Tim Vaillancourt <[email protected]>
Co-authored-by: Andrew Mason <[email protected]>
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
RainbowDashy pushed a commit to bytebase/gh-ost that referenced this pull request Dec 13, 2022
d-bytebase pushed a commit to bytebase/gh-ost that referenced this pull request Dec 13, 2022
* Add script and docs for linter (github#1151)

* Enable more `golang-ci` linters (github#1149)

* Only build RPM and deb packages for amd64

* Convert character to bytes and insert into table using latin1

* delete junk files

* restore connection charset to utf8mb4

* Allow zero in dates (github#1161)

* Merge pull request #31 from openark/zero-date

Support zero date and zero in date, via dedicated command line flag

* Merge pull request #32 from openark/existing-date-with-zero

Support tables with existing zero dates

* Remove un-needed ignore_versions file

* Fix new lint errors from golang-ci update

Co-authored-by: Shlomi Noach <[email protected]>

* Add missing doc from PR github#1131 (github#1162)

* Set a transaction isolation level for MySQL connections (github#1156)

* Set transaction isolation in connections

* Revert load_map.go change

* Var rename

* Restore comment

* Some fix to unit tests.

* convert to bytes if character string without charsetConversion.

* chore: remove duplicate word in comments (github#1175)

Signed-off-by: Abirdcfly <[email protected]>

Signed-off-by: Abirdcfly <[email protected]>

* Improve applier `.ReadMigrationRangeValues()` func accuracy (github#1164)

* Use a transaction in applier `ReadMigrationRangeValues` func

* Private func names

* Add basic tests for applier (github#1165)

* Add basic tests for applier

* Add header

* Add basic test for inspector (github#1166)

* Add basic test for inspector

* Add header

* Fix return

* Add basic tests to migrator (github#1168)

* add-rocksdb-as-transactional-engine

* Add basic test for hooks (github#1179)

* Enable more `golangci-lint` linters (github#1181)

* Print status to migration context logger

* fix CI tests to ubuntu-20.04 because ubuntu-22.04 (current -latest) doesn't support MySQL 5.7

* temp commit to investigate datetime-with-zero test failure

* more testing

* add extra debugging output

* debugging

* add error detection for test setup, sort tests to make it easier to track progress

* fix broken test by removing invalid insert statement

* Fix: Change table name

table name is 'tbl' not 'tble'

* Attempt instant DDL if supported

* minor cleanup

* Add tests, incorporate feedback

* Improve docs

* Address PR feedback

* Make it clear in docs it is disabled by default but safe.

* Update go/logic/migrator.go

Co-authored-by: dm-2 <[email protected]>

* remove useless func per review

* support rocksdb as transactional engine

* Modify tests to support rocksdb tests

* SetConnectionConfig

* add support for rocksdb

* add support for rocksdb

* add percona to versions in workflows

* add description and optimize tests

* Apply suggestions from code review

Co-authored-by: dm-2 <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tim Vaillancourt <[email protected]>

* Update go/logic/applier.go

Signed-off-by: Abirdcfly <[email protected]>
Co-authored-by: Tim Vaillancourt <[email protected]>
Co-authored-by: dm-2 <[email protected]>
Co-authored-by: wangzihuacool <[email protected]>
Co-authored-by: wangzihuacool <[email protected]>
Co-authored-by: Shlomi Noach <[email protected]>
Co-authored-by: Abirdcfly <[email protected]>
Co-authored-by: Nicholas Calugar <[email protected]>
Co-authored-by: Hasan Mshawrab <[email protected]>
Co-authored-by: Morgan Tocker <[email protected]>
Co-authored-by: Morgan Tocker <[email protected]>
Co-authored-by: lukelewang <[email protected]>
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
3 participants