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 WithContext and WithTimeout #92 #97

Merged
merged 11 commits into from Mar 30, 2021
Merged

Add WithContext and WithTimeout #92 #97

merged 11 commits into from Mar 30, 2021

Conversation

gtourkas
Copy link
Contributor

Overall I've followed the in-issue guide. Still need to look into a suspicious defer inside retryRequest but this will suffice for review.

Copy link
Owner

@gavv gavv left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Here are a few comments.

request.go Outdated Show resolved Hide resolved
request.go Show resolved Hide resolved
request.go Outdated Show resolved Hide resolved
request.go Outdated Show resolved Hide resolved
e2e_context_test.go Outdated Show resolved Hide resolved
e2e_context_test.go Outdated Show resolved Hide resolved
e2e_context_test.go Show resolved Hide resolved
@gtourkas
Copy link
Contributor Author

@gavv Pushed all the changes you requested.

request.go Outdated Show resolved Hide resolved
request.go Outdated Show resolved Hide resolved
e2e_context_test.go Outdated Show resolved Hide resolved
@gavv
Copy link
Owner

gavv commented Mar 25, 2021

Thanks for update! A few final minor comments.

@gavv
Copy link
Owner

gavv commented Mar 25, 2021

Still need to look into a suspicious defer inside retryRequest

Looks legit

@gavv
Copy link
Owner

gavv commented Mar 25, 2021

It seems there is a possible deadlock in the new tests.

I've run this:

go test -race -count=100 -v |& pp

(pp is https://github.com/maruel/panicparse)

And eventually TestPerRequestWithTimeoutAndWithRetries stucked and then terminated by timeout: https://gist.github.com/gavv/e9aa492ed0ca50e8073251099e9f9f7c

@gavv
Copy link
Owner

gavv commented Mar 25, 2021

(Also it seems that goroutines are leaking in TestE2EWebsocketTimeouts, but I think this is unrelated; those goroutines are excluded from trace)

@gtourkas
Copy link
Contributor Author

It seems there is a possible deadlock in the new tests.

I've run this:

go test -race -count=100 -v |& pp

(pp is https://github.com/maruel/panicparse)

And eventually TestPerRequestWithTimeoutAndWithRetries stucked and then terminated by timeout: https://gist.github.com/gavv/e9aa492ed0ca50e8073251099e9f9f7c

I'll look into this shortly.

@gtourkas
Copy link
Contributor Author

TestPerRequestWithTimeoutAndWithRetries

It seems there is a possible deadlock in the new tests.
I've run this:

go test -race -count=100 -v |& pp

(pp is https://github.com/maruel/panicparse)
And eventually TestPerRequestWithTimeoutAndWithRetries stucked and then terminated by timeout: https://gist.github.com/gavv/e9aa492ed0ca50e8073251099e9f9f7c

I'll look into this shortly.

@gavv can you reproduce with

go test -race -count=100 -v -run TestPerRequestWithTimeoutAndWithRetries

?

@gavv
Copy link
Owner

gavv commented Mar 25, 2021

Hm, yes, it's reproducing, but only without -run TestPerRequestWithTimeoutAndWithRetries. This time TestPerRequestWithTimeout was the failed test.

I guess that with -run conditions for the race are not met.

Another opportunity is that the problem is indirectly caused by other tests, e.g. by gorotuine leak mentioned above - I didn't try to debug it yet.

My env:

$ git status
On branch gtourkas/master
nothing to commit, working tree clean
$ git rev-parse HEAD
b06385b7aed0d723773e5aca4339881ed6c712fe
$ go version
go version go1.16.2 linux/amd64
$ uname -a
Linux tripbook 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux

@gtourkas
Copy link
Contributor Author

gtourkas commented Mar 26, 2021

@gavv I can reproduce as well. The problem is with the WithTimeout tests. There is no problem when omitted. I'll try to debug.

@gtourkas
Copy link
Contributor Author

gtourkas commented Mar 29, 2021

@gavv It seems that the problem is the default timeout for go test, which is 10m(inutes). A single test run lasts in my environment 6.317s(econds). For -count=100, this will be at least 631.7s>10m. Simply increasing the timeout to 11m will result in passing the test run:

go test -count=100 -timeout=11m

image

In any case, I've set the various WithTimeouts to 500ms so that the tests complete under the default 10m for count=100.

@gavv
Copy link
Owner

gavv commented Mar 30, 2021

Never mind, I expected the timeout is per-test... Thanks for looking into it and for the PR!

@gavv gavv merged commit 92531c1 into gavv:master Mar 30, 2021
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