|
|
Created:
6 years, 3 months ago by Jaekyun Seok (inactive) Modified:
6 years, 3 months ago CC:
chromium-reviews, mmenke Base URL:
https://chromium.googlesource.com/chromium/src.git@master Project:
chromium Visibility:
Public. |
DescriptionListen to OnNetworkChanged instead of OnIPAddressChanged
On android platform, it often fails to fetch searchdomaincheck url right
after network changes.
To fix the failure, this patch modifies GoogleURLTracker to listen to
OnNetworkChanged instead of OnIPAddressChanged.
BUG=407442
Committed: https://crrev.com/22b47697f6940fd76b8cb5fe5470abdd50c1a8ad
Cr-Commit-Position: refs/heads/master@{#293371}
Patch Set 1 #
Total comments: 3
Patch Set 2 : Apply retry on network changes on all platforms #Patch Set 3 : Listen to OnNetworkChanged instead of OnIPAddressChanged #Patch Set 4 : Remove retry configuration #Patch Set 5 : Update tests #
Messages
Total messages: 44 (4 generated)
jaekyun@chromium.org changed reviewers: + blundell@chromium.org, tedchoc@chromium.org
Please review this patch.
blundell@chromium.org changed reviewers: + pkasting@chromium.org
blundell -> pkasting PK is better-suited than me for the OWNERS review here.
https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... File components/google/core/browser/google_url_tracker.cc (right): https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... components/google/core/browser/google_url_tracker.cc:250: fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); Let me understand this. When the network changes, OnIPAddressChanged() gets called, which calls StartFetchIfDesirable(), but the fetch we subsequently trigger here can still fail with ERR_NETWORK_CHANGED after that? Why? Also, why is this Android-specific? Wouldn't we want this retry behavior on all platforms?
https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... File components/google/core/browser/google_url_tracker.cc (right): https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... components/google/core/browser/google_url_tracker.cc:250: fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); On 2014/08/27 19:52:46, Peter Kasting wrote: > Let me understand this. When the network changes, OnIPAddressChanged() gets > called, which calls StartFetchIfDesirable(), but the fetch we subsequently > trigger here can still fail with ERR_NETWORK_CHANGED after that? Why? Yes, that is correctly what happened on clank. I confirmed that when this problem happened HostResolverImpl::OnDNSChanged() was called right after GoogleURLTracker::OnIPAddressChanged() was called, and so HostResolverImpl::OnDNSChanged() aborted GoogleURLTracker's request. But this doesn't always happen, and so I think that this is timing problem. > > Also, why is this Android-specific? Wouldn't we want this retry behavior on all > platforms? Actually, I tested this only on clank, and so I applied this only on android to avoid any regression on other platforms. But I believe that this isn't harmful at all. I will remove if macro.
https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... File components/google/core/browser/google_url_tracker.cc (right): https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... components/google/core/browser/google_url_tracker.cc:250: fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); On 2014/08/28 02:00:52, Jaekyun Seok wrote: > On 2014/08/27 19:52:46, Peter Kasting wrote: > > Let me understand this. When the network changes, OnIPAddressChanged() gets > > called, which calls StartFetchIfDesirable(), but the fetch we subsequently > > trigger here can still fail with ERR_NETWORK_CHANGED after that? Why? > > Yes, that is correctly what happened on clank. > I confirmed that when this problem happened HostResolverImpl::OnDNSChanged() was > called right after GoogleURLTracker::OnIPAddressChanged() was called, and so > HostResolverImpl::OnDNSChanged() aborted GoogleURLTracker's request. But this > doesn't always happen, and so I think that this is timing problem. Hmm. Here are two ideas for a possible better fix: (1) Ensure that HostResolverImpl::OnDNSChanged() gets called before any OnIPAddressChanged() methods get called, so no on tries to do network accesses that will immediately get aborted. (2) Have OnIPAddressChanged() post a task to do the network access, so we finish calling all the various handlers before we try to do this. (1) is better than (2), if it would work, since (2) is basically a hack. Either one seems better than the current fix, though, since the current fix doesn't prevent us from doing extra work that will fail, it just retries if we do so. The network stack folks should probably weigh in.
On 2014/08/28 03:28:20, Peter Kasting wrote: > https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... > File components/google/core/browser/google_url_tracker.cc (right): > > https://codereview.chromium.org/512843002/diff/1/components/google/core/brows... > components/google/core/browser/google_url_tracker.cc:250: > fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); > On 2014/08/28 02:00:52, Jaekyun Seok wrote: > > On 2014/08/27 19:52:46, Peter Kasting wrote: > > > Let me understand this. When the network changes, OnIPAddressChanged() gets > > > called, which calls StartFetchIfDesirable(), but the fetch we subsequently > > > trigger here can still fail with ERR_NETWORK_CHANGED after that? Why? > > > > Yes, that is correctly what happened on clank. > > I confirmed that when this problem happened HostResolverImpl::OnDNSChanged() > was > > called right after GoogleURLTracker::OnIPAddressChanged() was called, and so > > HostResolverImpl::OnDNSChanged() aborted GoogleURLTracker's request. But this > > doesn't always happen, and so I think that this is timing problem. > > Hmm. Here are two ideas for a possible better fix: > (1) Ensure that HostResolverImpl::OnDNSChanged() gets called before any > OnIPAddressChanged() methods get called, so no on tries to do network accesses > that will immediately get aborted. > (2) Have OnIPAddressChanged() post a task to do the network access, so we finish > calling all the various handlers before we try to do this. > > (1) is better than (2), if it would work, since (2) is basically a hack. Either > one seems better than the current fix, though, since the current fix doesn't > prevent us from doing extra work that will fail, it just retries if we do so. > > The network stack folks should probably weigh in. For solution (1), HostResolverImpl::OnDNSChanged() is called due to DNSObserver::OnDNSChanged event, and GoogleURLTracker::OnIPAddressChanged() is called due to IPAddressObserver::OnIPAddressChanged event. But the two events are generated by two different sources; DnsConfigService (jni) and NetworkChangeNotifier (java) on android. So serializing them doesn't seem easy. For solution (2), I don't understand this. For now GoogleURLTracker::OnIPAddressChanged() internally is posting a task to do the network access, and the task is aborted by HostResolverImpl::OnDNSChanged() in this problem. I want to suggest another solution which handles DNSObserver::OnDNSChanged event separately inside GoogleURLTracker. This solution will fix the problem regardless of the timing of DNSObserver::OnDNSChanged and IPAddressObserver::OnIPAddressChanged events because StartFetchIfDesirable() will be called again by DNSObserver::OnDNSChanged event. What do you think of this? And could you please add any network stack folks as reviewers if you know some?
pkasting@chromium.org changed reviewers: + rsleevi@chromium.org
Ryan, I'm looking for some network stack guidance on the best solution to the problem here. Please see the last few comments on this review for the relevant discussion. On 2014/08/28 05:17:26, Jaekyun Seok wrote: > For solution (1), > HostResolverImpl::OnDNSChanged() is called due to DNSObserver::OnDNSChanged > event, and GoogleURLTracker::OnIPAddressChanged() is called due to > IPAddressObserver::OnIPAddressChanged event. But the two events are generated by > two different sources; DnsConfigService (jni) and NetworkChangeNotifier (java) > on android. So serializing them doesn't seem easy. Ah... that's likely going to break (2) as well, since the callbacks aren't all happening during the same callstack. > I want to suggest another solution which handles DNSObserver::OnDNSChanged event > separately inside GoogleURLTracker. This solution will fix the problem > regardless of the timing of DNSObserver::OnDNSChanged and > IPAddressObserver::OnIPAddressChanged events because StartFetchIfDesirable() > will be called again by DNSObserver::OnDNSChanged event. Hmm. Maybe. In theory, GoogleURLTracker probably doesn't really care about DNS changes, just IP changes, since the latter can change the searchdomaincheck result but the former (in the absence of the latter) presumably can't. Which would imply that your current fix is better.
rsleevi@chromium.org changed reviewers: + pauljensen@chromium.org
I believe Paul may be better able to answer this. If not he, then mmenke@, cc'd. The best I can share is the general statement that "DNS and IP changes tend to mess everything up and make Chrome unusuable because so many systems start flapping", so thanks at least for trying to make something less flappybad.
(I just hit some magic key that closed my Chrome window with all my tabs and erased my comment....starting again....very angry....) I suggest changing from OnIpAddressChanged() to using OnNetworkChanged() and considering this use case a "constructive" use case. Here's my doc on the subject from long ago: https://docs.google.com/document/d/1ch22_dRHPQJ9QArFMmWl_UyVpl-EDXA0PdljGh2kD... I never got around to the very destabilizing work of converting all observers to OnNetworkChanged. Here's what I recommend: OnNetworkChanged(ConnectionType type) { // Ignore destructive signals. if (type == CONNECTION_NONE) return; already_fetched_ = false; StartFetchIfDesirable(); }
I should also mention, I'm fine if you want your URLFetcher to retry on ERR_NETWORK_CHANGED too, but I'd recommend trying OnNetworkChanged first as I think it more directly addresses your concern, rather than papers over it.
Thanks Paul, that sounds like a good plan. Jaekyun, want to implement this?
On 2014/08/29 18:16:17, Peter Kasting wrote: > Thanks Paul, that sounds like a good plan. > > Jaekyun, want to implement this? Yes, I will try next week.
PTAL. I modified this patch to listen to OnNetworkChanged instead of OnIPAddressChanged. I confirmed that it resolved the original issue. But I left the logic to configure max retries for ERR_NETWORK_CHANGED for some occasional cases.
After testing more without configuring max retries for ERR_NETWORK_CHANGED, I confirmed that the original issue sometimes happened even after listening to OnNetworkChanged. So, I believe that configuring max retries for ERR_NETWORK_CHANGED is needed anyway.
Can you elaborate on the circumstances that cause it to fail and require increasing the retry count? A net-internals log of an example failure without retrying enabled would be very helpful, you can use chrome://net-export on Android to collect such a log.
I agree. The network change observer stuff looks fine, but continuing to need retries on ERR_NETWORK_CHANGED seems unfortunate.
You can see the net-internals log between network change and failure of fetching in https://drive.google.com/a/google.com/file/d/0B0rlutRlVuQKT2lwU2ZybVJnclk/vie... . And I confirmed that the failure sequence was as same as before. HostResolverImpl::OnDNSChanged() was triggered by DNSObserver::OnDNSChanged event right after GoogleURLTracker::OnNetworkChanged() was triggered by NetworkChangeObserver::OnNetworkChanged event, and so HostResolverImpl::OnDNSChanged() aborted GoogleURLTracker's request.
On 2014/09/02 23:23:06, Jaekyun Seok wrote: > You can see the net-internals log between network change and failure of fetching > in > https://drive.google.com/a/google.com/file/d/0B0rlutRlVuQKT2lwU2ZybVJnclk/vie... > . > > And I confirmed that the failure sequence was as same as before. > HostResolverImpl::OnDNSChanged() was > triggered by DNSObserver::OnDNSChanged event right after > GoogleURLTracker::OnNetworkChanged() was triggered by > NetworkChangeObserver::OnNetworkChanged event, and so > HostResolverImpl::OnDNSChanged() aborted GoogleURLTracker's request. Should we be making HostResolverImpl respond to network change events instead? Should we ensure that network change events are sent later than DNS change events?
rsleevi@chromium.org changed reviewers: - rsleevi@chromium.org
I filed http://crbug.com/410304 to make the network change events.
On 2014/09/03 14:53:56, pauljensen wrote: > I filed http://crbug.com/410304 to make the network change events. to make the network change events ... ?
I filed http://crbug.com/410304 to make the network change events come after the DNS changed events. (Sorry dunno what happened to the end of that sentence.)
Then, will this patch keep going separately, or do you want me to abandon it?
On 2014/09/03 21:27:21, Jaekyun Seok wrote: > Then, will this patch keep going separately, or do you want me to abandon it? Why don't you commit the portions of it that switch to listening to NetworkChanged events. That should at least improve the code. The network changed retry bit we can leave out unless it becomes clear we'll end up needing it.
Without the network changed retry bit this change isn't related to the original bug at all. And I think it isn't harmful anyway even though the network change events come after the DNS changed events. Maybe we can use it as a workaround until http://crbug.com/410304 is fixed. So my suggestion is to keep the line with TODO comments that its necessity should be re-checked after http://crbug.com/410304 is fixed. How about my suggestion?
I would really rather not add that line, even if it works around this bug for now, until we at least have a schedule for fixing the other bug and Paul has a chance to respond to my question there. This isn't unrelated to the original bug. Changing which event we listen to may make things work better, especially on non-Android platforms.
OK. I will remove the line for the network changed retry bit in this change. And after seeing to Paul's response I will make a separate change for the network changed retry bit if necessary.
PTAL. I removed the network changed retry.
LGTM
The CQ bit was checked by jaekyun@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jaekyun@chromium.org/512843002/60001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_clang_dbg_recipe on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_clang_d...) android_dbg_tests_recipe on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_dbg_tes...) win_chromium_x64_rel_swarming on tryserver.chromium.win (http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
PTAL. I updated tests to fix failures on unittests.
Paul, please take a look at changes on network_change_notifier.h/cc.
net/ LGTM
The CQ bit was checked by jaekyun@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jaekyun@chromium.org/512843002/80001
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as f5cff07e7f19d02993e06062d14282978beed20b
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/22b47697f6940fd76b8cb5fe5470abdd50c1a8ad Cr-Commit-Position: refs/heads/master@{#293371} |