-
Notifications
You must be signed in to change notification settings - Fork 753
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
Currency tests failing sporadically #722
Comments
To reproduce locally, run this. It might take a few tries:
|
Updated the original comment with better info. For now this has been removed through #723 because |
I believe the problem with failed http requests stems from concurrent requests to the mock server. If you lower the number of workers/interval frequency to insure that one call to the mock server completes before the next time it is called, will that mean we have essentially lowered the race condition test to effectively a single threaded entity? I expect the http processing through the loop back device makes the http call the longest process running. If that never overlaps itself, how often do we expect that processing the rates will land just on the border of the rate update and thus exercise the race condition potential? I would rather see a solution where the rate of currency conversions isn't limited to match the rate of sequential calls to update the rates. Perhaps have one goroutine run a tight loop calling the mock server, and a collection of other goroutines calling for rate conversions only. The code already limits to only one update call at a time, so no need to allow two updates to try to process concurrently. |
One easy way to fix the server connection issue is to send a mock version of the
Send this into |
Hey @dbemiller and @hhhjort, Sorry for this one. First regarding
Those warnings are expected since those relate to either bad JSON or bad URL test, so looks normal to me. Regarding the others
are indeed an issue. Regarding
I did that before but moved to httptest lib instead not to have to create a mock following |
No worries at all. Re: log messages, that makes a lot of sense. I talked to @hhhjort here too, and had another suggestion. Basically just limit "updates" to a single goroutine, but still have many Readers. This should stop the OS from getting overloaded with connections (although I didn't test it), and more closely matches how prod would work anyway. There are some tradeoffs to each option... so both sound fine to me as long as they check the concurrency & pass reliably. |
Ok, I will test the later option and keep you posted, I will launch test on a test computer here as well. Maybe we can try to keep couple readers because an Do you think we need to introduce a system to prevent such httpClient overload by maybe:
|
And indeed, using an HttpClientMock does the trick. I don't see any warnings / errors locally but only warnings regarding bad JSONs and bad URLs.
|
No. The It's also a good thing that you're doing lots of reads & writes in a short time. The more reads & writes in a short time, the better chance your code exhibits "race-y" behavior that the race detector can catch. Limiting writes to one goroutine is just a compromise to work around this connection issue. It's actually less likely to stumble on race conditions this way... but since it'd still be doing concurrent reads & writes, the test would still add value because the chance is non-zero. |
Well, as you guys prefer, I personally kind of like having an HTTPClientMock taking no time for this test and have a lot of writers / readers so it really tests the concurrency. If you prefer having only one writer for this test I am also ok with it but I feel like it might not represent the real usage. |
both are fine :) |
Both are fine with me as well. |
This CL introduces a mechanism to fetch currencies rates periodically from a remote source. Those rates are stored in `CurrencyConverter` struct which can be injected in PBS to get rates. This doesn't introduce any changes in PBS workflow just yet. It also address issues described in prebid#722 regarding httptestClient overload in tests generating errors while running `validate.sh` script. Issue: prebid#280
This CL introduces a mechanism to fetch currencies rates periodically from a remote source. Those rates are stored in `CurrencyConverter` struct which can be injected in PBS to get rates. This doesn't introduce any changes in PBS workflow just yet. It also address issues described in #722 regarding httptestClient overload in tests generating errors while running `validate.sh` script. Issue: #280
This CL introduces a mechanism to fetch currencies rates periodically from a remote source. Those rates are stored in `CurrencyConverter` struct which can be injected in PBS to get rates. This doesn't introduce any changes in PBS workflow just yet. It also address issues described in prebid#722 regarding httptestClient overload in tests generating errors while running `validate.sh` script. Issue: prebid#280
This CL introduces a mechanism to fetch currencies rates periodically from a remote source. Those rates are stored in `CurrencyConverter` struct which can be injected in PBS to get rates. This doesn't introduce any changes in PBS workflow just yet. It also address issues described in prebid#722 regarding httptestClient overload in tests generating errors while running `validate.sh` script. Issue: prebid#280
This CL introduces a mechanism to fetch currencies rates periodically from a remote source. Those rates are stored in `CurrencyConverter` struct which can be injected in PBS to get rates. This doesn't introduce any changes in PBS workflow just yet. It also address issues described in prebid#722 regarding httptestClient overload in tests generating errors while running `validate.sh` script. Issue: prebid#280
I saw lots of errors like this while running
./validate.sh
locally. There seem to be two unrelated problems.The first is an
os.SyscallError
when trying to fetch conversion rates:This is on a Macbook Pro. The message:
root error was: connect: can't assign requested address
comes from some custom code I added to unwrap thenet.OpError
that shows up as a pointer in the original message.I suspect Travis didn't have these because it runs tests on a different OS.
The second does not reproduce consistently... but it's not rare either. I suspect Travis didn't catch it because the failures are intermittent.
This is probably due to a race condition that the race detector doesn't pick up, but nevertheless exists.
I'm not sure whether or not these are expected... but I'll put them down here as extra info. There are a big string of log messages before the test finally fails:
The text was updated successfully, but these errors were encountered: