Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Issue 23717047: Retry: sync: Gracefully handle early shutdown (Closed)

Created:
7 years, 3 months ago by rlarocque
Modified:
7 years, 3 months ago
CC:
chromium-reviews, tim+watch_chromium.org, cbentzel+watch_chromium.org, rsimha+watch_chromium.org, haitaol+watch_chromium.org
Visibility:
Public.

Description

sync: Gracefully handle early shutdown Introduce a new object to communicate cross-thread cancellation signals. This new object, the CancellationSignal, is protected by a lock. It allows the receiving thread to query whether or not a stop has been requested. It also allows the receiving thread to safely register a cross-thread callback to be invoked immediately when a stop is requested. We use two instances of this class to ensure we meet all the requirements for a safe and fast sync backend shutdown. The first instance is used with the HttpBridgeFactory to allow the UI thread to force it to drop all refereces to its RequestContextGetter immediately. This is an important part of our plan to ensure that all references to that object are released before ProfileSyncService::Shutdown() returns, which is necessary to avoid racy crashes at shutdown. (See crbug.com/236451) The second instance is used with the ServerConnectionManager and the Syncer. Once signalled, it ensures that any active connections are released (possibly decrementing another ref to the RequestContextGetter), that any blocking I/O is aborted, and that no more connections will be instantiated. It's important to prevent the creation of more connections because the HttpBridgeFactory might trigger a crash if we asked it to create another connection after it had been shut down. The syncer's interaction with the second cancelation signal is more passive. It does not execute any callbacks when the signal is sent. Instead, it queries the signal as it performs sync cycles, and will cut short any existing sync cycle if it notices the signal has been sent. Finally, this CL includes one important change to the initialization of the HttpBridgeFactory. In order to properly register with the cancellation signal while still allowing the creation of the user agent to occur on the sync thread, its initialization had to be split into two parts. This class now has an Init() method in addition to its constructor. BUG=236451 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=224014

Patch Set 1 #

Total comments: 1

Patch Set 2 : First attempt at rebase #

Patch Set 3 : Small cleanups + fixes #

Patch Set 4 : Split up HttpBridgeFactory init #

Patch Set 5 : Fix sync_client compile #

Patch Set 6 : Minor comment and style improvements #

Total comments: 4

Patch Set 7 : Add comment #

Patch Set 8 : Move signals to SyncaBackendHost::Core #

Total comments: 10

Patch Set 9 : Some comments and renames #

Patch Set 10 : Rebase #

Patch Set 11 : Renames #

Unified diffs Side-by-side diffs Delta from patch set Stats (+644 lines, -203 lines) Patch
M chrome/browser/sync/glue/sync_backend_host.h View 1 2 3 4 5 6 7 5 chunks +5 lines, -13 lines 0 comments Download
M chrome/browser/sync/glue/sync_backend_host.cc View 1 2 3 4 5 6 7 8 9 10 14 chunks +56 lines, -45 lines 0 comments Download
M chrome/browser/sync/test/test_http_bridge_factory.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/sync/test/test_http_bridge_factory.cc View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/sync/test_profile_sync_service.cc View 1 1 chunk +1 line, -2 lines 0 comments Download
M sync/engine/net/server_connection_manager.h View 1 2 3 4 5 6 7 8 9 10 6 chunks +10 lines, -3 lines 0 comments Download
M sync/engine/net/server_connection_manager.cc View 1 2 3 4 5 6 7 8 9 10 4 chunks +17 lines, -3 lines 0 comments Download
M sync/engine/sync_scheduler.h View 1 chunk +3 lines, -5 lines 0 comments Download
M sync/engine/sync_scheduler_impl.h View 2 chunks +1 line, -4 lines 0 comments Download
M sync/engine/sync_scheduler_impl.cc View 4 chunks +5 lines, -13 lines 0 comments Download
M sync/engine/sync_scheduler_unittest.cc View 1 5 chunks +8 lines, -1 line 0 comments Download
M sync/engine/syncer.h View 3 chunks +4 lines, -6 lines 0 comments Download
M sync/engine/syncer.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -9 lines 0 comments Download
M sync/engine/syncer_proto_util_unittest.cc View 1 3 chunks +5 lines, -3 lines 0 comments Download
M sync/engine/syncer_unittest.cc View 1 2 3 4 5 6 7 8 9 4 chunks +5 lines, -2 lines 0 comments Download
M sync/internal_api/http_bridge.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +38 lines, -9 lines 0 comments Download
M sync/internal_api/http_bridge_unittest.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +11 lines, -5 lines 0 comments Download
M sync/internal_api/internal_components_factory_impl.cc View 1 chunk +8 lines, -3 lines 0 comments Download
A sync/internal_api/public/base/cancelation_observer.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +25 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_observer.cc View 1 chunk +13 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_signal.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +72 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_signal.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +52 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_signal_unittest.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +169 lines, -0 lines 0 comments Download
M sync/internal_api/public/http_bridge.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +24 lines, -8 lines 0 comments Download
M sync/internal_api/public/http_post_provider_factory.h View 1 2 3 3 chunks +4 lines, -4 lines 0 comments Download
M sync/internal_api/public/internal_components_factory.h View 2 chunks +3 lines, -1 line 0 comments Download
M sync/internal_api/public/internal_components_factory_impl.h View 1 chunk +2 lines, -1 line 0 comments Download
M sync/internal_api/public/sync_manager.h View 1 2 3 4 5 6 7 8 4 chunks +6 lines, -12 lines 0 comments Download
M sync/internal_api/public/test/fake_sync_manager.h View 2 chunks +2 lines, -2 lines 0 comments Download
M sync/internal_api/public/test/test_internal_components_factory.h View 1 chunk +2 lines, -1 line 0 comments Download
M sync/internal_api/sync_manager_impl.h View 2 chunks +2 lines, -2 lines 0 comments Download
M sync/internal_api/sync_manager_impl.cc View 5 chunks +6 lines, -10 lines 0 comments Download
M sync/internal_api/sync_manager_impl_unittest.cc View 1 2 3 4 5 6 7 8 9 5 chunks +7 lines, -3 lines 0 comments Download
M sync/internal_api/syncapi_server_connection_manager.h View 1 1 chunk +4 lines, -2 lines 0 comments Download
M sync/internal_api/syncapi_server_connection_manager.cc View 1 2 chunks +7 lines, -7 lines 0 comments Download
M sync/internal_api/syncapi_server_connection_manager_unittest.cc View 1 2 3 4 5 6 7 8 9 10 4 chunks +29 lines, -6 lines 0 comments Download
M sync/internal_api/test/fake_sync_manager.cc View 2 chunks +2 lines, -4 lines 0 comments Download
M sync/internal_api/test/test_internal_components_factory.cc View 1 chunk +3 lines, -1 line 0 comments Download
M sync/sync_internal_api.gypi View 2 chunks +5 lines, -1 line 0 comments Download
M sync/sync_tests.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M sync/test/engine/fake_sync_scheduler.h View 1 chunk +1 line, -1 line 0 comments Download
M sync/test/engine/fake_sync_scheduler.cc View 1 chunk +1 line, -1 line 0 comments Download
M sync/test/engine/mock_connection_manager.h View 1 2 chunks +3 lines, -1 line 0 comments Download
M sync/test/engine/mock_connection_manager.cc View 1 1 chunk +3 lines, -2 lines 0 comments Download
M sync/test/engine/syncer_command_test.h View 1 3 chunks +4 lines, -1 line 0 comments Download
M sync/tools/sync_client.cc View 1 2 3 4 4 chunks +8 lines, -3 lines 0 comments Download

Messages

Total messages: 24 (0 generated)
rlarocque
Tim, Haitao: PTAL. This is a retry of https://chromiumcodereview.appspot.com/23189021. That CL was reverted because there ...
7 years, 3 months ago (2013-09-10 19:16:00 UTC) #1
haitaol1
https://codereview.chromium.org/23717047/diff/1/sync/internal_api/public/sync_manager.h File sync/internal_api/public/sync_manager.h (left): https://codereview.chromium.org/23717047/diff/1/sync/internal_api/public/sync_manager.h#oldcode404 sync/internal_api/public/sync_manager.h:404: virtual void StopSyncingForShutdown() = 0; 22901013 depends on this ...
7 years, 3 months ago (2013-09-10 20:36:27 UTC) #2
tim (not reviewing)
On 2013/09/10 20:36:27, haitaol1 wrote: > https://codereview.chromium.org/23717047/diff/1/sync/internal_api/public/sync_manager.h > File sync/internal_api/public/sync_manager.h (left): > > https://codereview.chromium.org/23717047/diff/1/sync/internal_api/public/sync_manager.h#oldcode404 > ...
7 years, 3 months ago (2013-09-11 16:21:54 UTC) #3
rlarocque
It's not going to win any beauty contests, but I think this patch can fix ...
7 years, 3 months ago (2013-09-12 23:53:13 UTC) #4
haitaol1
https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.h File chrome/browser/sync/glue/sync_backend_host.h (right): https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.h#newcode592 chrome/browser/sync/glue/sync_backend_host.h:592: scoped_ptr<syncer::CancelationSignal> factory_cancelation_signal_; Maybe move these into SyncBackendRegistrar, which is ...
7 years, 3 months ago (2013-09-13 18:43:21 UTC) #5
rlarocque
https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.h File chrome/browser/sync/glue/sync_backend_host.h (right): https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.h#newcode592 chrome/browser/sync/glue/sync_backend_host.h:592: scoped_ptr<syncer::CancelationSignal> factory_cancelation_signal_; On 2013/09/13 18:43:21, haitaol1 wrote: > Maybe ...
7 years, 3 months ago (2013-09-13 20:27:17 UTC) #6
haitaol1
lgtm
7 years, 3 months ago (2013-09-13 22:18:36 UTC) #7
tim (not reviewing)
https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.cc#newcode206 chrome/browser/sync/glue/sync_backend_host.cc:206: scoped_ptr<syncer::CancelationSignal> signal1, Explain here why we pass ownership of ...
7 years, 3 months ago (2013-09-16 18:30:11 UTC) #8
rlarocque
Patch updated. https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.cc#newcode206 chrome/browser/sync/glue/sync_backend_host.cc:206: scoped_ptr<syncer::CancelationSignal> signal1, On 2013/09/16 18:30:11, timsteele wrote: ...
7 years, 3 months ago (2013-09-16 18:39:09 UTC) #9
tim (not reviewing)
On 2013/09/16 18:39:09, rlarocque wrote: > Patch updated. > > https://codereview.chromium.org/23717047/diff/25001/chrome/browser/sync/glue/sync_backend_host.cc > File chrome/browser/sync/glue/sync_backend_host.cc (right): ...
7 years, 3 months ago (2013-09-16 19:47:12 UTC) #10
tim (not reviewing)
tl;dr was I think this change LGTM, but if you can think of a better ...
7 years, 3 months ago (2013-09-16 20:01:35 UTC) #11
rlarocque
On 2013/09/16 20:01:35, timsteele wrote: > tl;dr was I think this change LGTM, but if ...
7 years, 3 months ago (2013-09-16 21:26:57 UTC) #12
tim (not reviewing)
Ah, this looks nicer. I'll take one more look after comments addressed. https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc ...
7 years, 3 months ago (2013-09-16 23:01:30 UTC) #13
rlarocque
Updated. https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc#newcode243 chrome/browser/sync/glue/sync_backend_host.cc:243: return &factory_cancelation_signal_; On 2013/09/16 23:01:31, timsteele wrote: > ...
7 years, 3 months ago (2013-09-17 00:03:21 UTC) #14
tim (not reviewing)
https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc#newcode243 chrome/browser/sync/glue/sync_backend_host.cc:243: return &factory_cancelation_signal_; On 2013/09/17 00:03:22, rlarocque wrote: > On ...
7 years, 3 months ago (2013-09-17 21:56:40 UTC) #15
rlarocque
https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc#newcode243 chrome/browser/sync/glue/sync_backend_host.cc:243: return &factory_cancelation_signal_; On 2013/09/17 21:56:41, timsteele wrote: > On ...
7 years, 3 months ago (2013-09-17 22:46:02 UTC) #16
tim (not reviewing)
https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc#newcode243 chrome/browser/sync/glue/sync_backend_host.cc:243: return &factory_cancelation_signal_; On 2013/09/17 22:46:02, rlarocque wrote: > On ...
7 years, 3 months ago (2013-09-18 00:37:55 UTC) #17
rlarocque
https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc File chrome/browser/sync/glue/sync_backend_host.cc (right): https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc#newcode243 chrome/browser/sync/glue/sync_backend_host.cc:243: return &factory_cancelation_signal_; On 2013/09/18 00:37:56, timsteele wrote: > On ...
7 years, 3 months ago (2013-09-18 00:45:08 UTC) #18
tim (not reviewing)
On 2013/09/18 00:45:08, rlarocque wrote: > https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc > File chrome/browser/sync/glue/sync_backend_host.cc (right): > > https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc#newcode243 > ...
7 years, 3 months ago (2013-09-18 01:41:50 UTC) #19
rlarocque
On 2013/09/18 01:41:50, timsteele wrote: > On 2013/09/18 00:45:08, rlarocque wrote: > > > https://codereview.chromium.org/23717047/diff/39001/chrome/browser/sync/glue/sync_backend_host.cc ...
7 years, 3 months ago (2013-09-18 18:34:12 UTC) #20
rlarocque
On 2013/09/18 18:34:12, rlarocque wrote: > On 2013/09/18 01:41:50, timsteele wrote: > > On 2013/09/18 ...
7 years, 3 months ago (2013-09-18 19:08:11 UTC) #21
tim (not reviewing)
Yeah, that sounds good. LGTM
7 years, 3 months ago (2013-09-18 20:00:46 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rlarocque@chromium.org/23717047/59001
7 years, 3 months ago (2013-09-18 20:08:35 UTC) #23
commit-bot: I haz the power
7 years, 3 months ago (2013-09-19 01:17:04 UTC) #24
Message was sent while issue was closed.
Change committed as 224014

Powered by Google App Engine
This is Rietveld 408576698