-
Notifications
You must be signed in to change notification settings - Fork 46
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
Introduce IdPool interface #52
Conversation
I'm not entirely convinced that this caused issue #48. But this is a nice addition to the current code base. Please rebase on the current master branch. I will merge after this. |
d9030db
to
eab1288
Compare
@yookoala I improved the PR a bit. Is this the right direction? I'm getting stuck with the tests, and fail to fix it properly. Could you advice me? 🙏 |
@ruudk: The newly written dynamic id pool has some data race issue. I believe the go routine line 58 in Check these links out to see if you get any inspiration: |
And introduce 2 implementations: DynamicIdPool (current implementation) and a new StaticIdPool that always allocates the same number. This could be used by projects that don't need to have an always running goroutine that generates ids (Skipper for example).
This will be a breaking change because it will prevent calling `ServeHTTP` multiple times on a `gofast.NewHandler`. This is something that is happening inside `example/php/php_test.go:TestNewSimpleHandler`. I'm not sure if that is even a good thing to do.
eab1288
to
20ac4c5
Compare
I think that Client.Close() should close the IdPool too. Because `ServeHTTP` in `gofast.NewHandler` will always defer `Client.Close()` I think it means that `ServeHTTP` can not be called multiple times. Therefore I decided to rewrite the tests to make it pass.
20ac4c5
to
f674ebf
Compare
@yookoala Today I decided to give this another shot and I was able to fix the race condition I added multiple commits because this is not 100% ready to merge yet. I would first want to get your opinion on how to solve this properly. In 97b6027 I added a I thought this might be a breaking change, so I removed it, to get the tests passing again in 4a2618a But I feel it should be done like this: f674ebf What do you think? |
I verified that this PR fixes the Skipper goroutine leak 🎉 |
When rerun the test, the racing is gone. This is probably due to some minor difference in the parallel steps in initialization. I'll check on this more. |
Any update? 🙏 |
Still testing if I can get rid of the occasional race condition. Please wait. |
After debugging Skipper's goroutine leak, @adri came with the idea to completely disable the dynamic id pool for Skipper.
I think it makes sense, as Skipper doesn't need this pool because it creates and destroys clients for every request.
Therefore, this PR introduces an IdPool interface with 2 implementations: DynamicIdPool (current implementation) and a new StaticIdPool that always allocates the same number.
This could be used by projects that don't need to have an always running goroutine that generates ids (Skipper for example).
Todo
ClientFactory
that creates a client with static id pool@yookoala WDYT about this? Would this make sense?