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

Issue 23189021: sync: Gracefully handle very early shutdown (Closed)

Created:
7 years, 4 months ago by rlarocque
Modified:
7 years, 2 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 very 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. This class is used to reimplement the UI thread to sync thread early shutdown signal. Previously, the UI thread would try to call in to objects owned by the sync thread. This required a workaround if the signal arrived very early, since we couldn't guarantee the sync thread had actually created those objects until later. The CancellationSignal is owned by the UI thread, so it is safe to call its RequestStop() at any point during sync initialization. The sync thread will receive the signal when it's ready. The new scheme has a few advantages over the old: - Thread ownership is simpler. The SyncBackendHost::Core, SyncManager, ServerConnectionManager, SyncScheduler and Syncer can now claim that all their member functions run on the sync thread. - We no longer need to implement special case logic for when a shutdown is requested before the SyncManager has initialized. - In a future CL, we can take advantage of the fact that we no longer require the special case to reduce inter-thread communication during sync startup. This will make startup simpler and, in some cases, improve sync startup time by as much as a few hundred milliseconds. - This will make it easier to address crbug.com/236451. BUG=236451 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=222154

Patch Set 1 #

Patch Set 2 : Make cancellation signal more generic #

Patch Set 3 : Fix sync_client compile #

Total comments: 24

Patch Set 4 : Fixes for first set of review comments #

Total comments: 14

Patch Set 5 : Review fixes #

Patch Set 6 : Fix sync_client.cc compile #

Total comments: 1

Patch Set 7 : Actually fix sync_client.cc compile #

Patch Set 8 : Retry: sync non-blocking early shutdown #

Unified diffs Side-by-side diffs Delta from patch set Stats (+552 lines, -215 lines) Patch
M chrome/browser/sync/glue/sync_backend_host.h View 1 2 3 4 5 6 7 6 chunks +9 lines, -9 lines 0 comments Download
M chrome/browser/sync/glue/sync_backend_host.cc View 1 2 3 4 5 6 7 10 chunks +33 lines, -33 lines 0 comments Download
M sync/engine/net/server_connection_manager.h View 1 2 3 4 6 chunks +25 lines, -34 lines 0 comments Download
M sync/engine/net/server_connection_manager.cc View 1 2 3 4 5 chunks +32 lines, -45 lines 0 comments Download
M sync/engine/sync_scheduler.h View 1 2 3 1 chunk +3 lines, -5 lines 0 comments Download
M sync/engine/sync_scheduler_impl.h View 1 2 3 2 chunks +1 line, -4 lines 0 comments Download
M sync/engine/sync_scheduler_impl.cc View 1 2 3 4 chunks +5 lines, -13 lines 0 comments Download
M sync/engine/sync_scheduler_unittest.cc View 1 2 3 2 chunks +4 lines, -0 lines 0 comments Download
M sync/engine/syncer.h View 1 2 3 3 chunks +4 lines, -6 lines 0 comments Download
M sync/engine/syncer.cc View 1 2 3 2 chunks +4 lines, -9 lines 0 comments Download
M sync/engine/syncer_proto_util_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M sync/engine/syncer_unittest.cc View 1 2 3 3 chunks +3 lines, -1 line 0 comments Download
M sync/internal_api/internal_components_factory_impl.cc View 1 2 3 1 chunk +8 lines, -3 lines 0 comments Download
A sync/internal_api/public/base/cancelation_observer.h View 1 2 3 4 1 chunk +25 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_observer.cc View 1 2 3 4 1 chunk +13 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_signal.h View 1 2 3 4 1 chunk +72 lines, -0 lines 0 comments Download
A sync/internal_api/public/base/cancelation_signal.cc View 1 2 3 4 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 1 chunk +168 lines, -0 lines 0 comments Download
M sync/internal_api/public/internal_components_factory.h View 1 2 3 2 chunks +3 lines, -1 line 0 comments Download
M sync/internal_api/public/internal_components_factory_impl.h View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M sync/internal_api/public/sync_manager.h View 1 2 3 3 chunks +3 lines, -12 lines 0 comments Download
M sync/internal_api/public/test/fake_sync_manager.h View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M sync/internal_api/public/test/test_internal_components_factory.h View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M sync/internal_api/sync_manager_impl.h View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M sync/internal_api/sync_manager_impl.cc View 1 2 3 5 chunks +6 lines, -10 lines 0 comments Download
M sync/internal_api/sync_manager_impl_unittest.cc View 1 2 3 4 chunks +6 lines, -2 lines 0 comments Download
M sync/internal_api/syncapi_server_connection_manager.h View 1 2 3 2 chunks +7 lines, -2 lines 0 comments Download
M sync/internal_api/syncapi_server_connection_manager.cc View 1 2 3 1 chunk +10 lines, -4 lines 0 comments Download
M sync/internal_api/syncapi_server_connection_manager_unittest.cc View 1 2 3 4 chunks +28 lines, -5 lines 0 comments Download
M sync/internal_api/test/fake_sync_manager.cc View 1 2 3 2 chunks +2 lines, -4 lines 0 comments Download
M sync/internal_api/test/test_internal_components_factory.cc View 1 2 3 1 chunk +3 lines, -1 line 0 comments Download
M sync/sync_internal_api.gypi View 1 2 3 2 chunks +5 lines, -1 line 0 comments Download
M sync/sync_tests.gypi View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M sync/test/engine/fake_sync_scheduler.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M sync/test/engine/fake_sync_scheduler.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M sync/test/engine/mock_connection_manager.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M sync/test/engine/mock_connection_manager.cc View 1 chunk +1 line, -1 line 0 comments Download
M sync/tools/sync_client.cc View 1 2 3 4 5 6 3 chunks +4 lines, -1 line 0 comments Download

Messages

Total messages: 16 (0 generated)
rlarocque
+Fred, since he understands threading pretty well and would likely notice if we've just re-implemented ...
7 years, 3 months ago (2013-08-27 22:06:37 UTC) #1
rlarocque
On 2013/08/27 22:06:37, rlarocque wrote: > +Fred, since he understands threading pretty well and would ...
7 years, 3 months ago (2013-09-04 23:20:18 UTC) #2
akalin
still looking, will finish by today https://codereview.chromium.org/23189021/diff/13001/sync/engine/net/server_connection_manager.cc File sync/engine/net/server_connection_manager.cc (right): https://codereview.chromium.org/23189021/diff/13001/sync/engine/net/server_connection_manager.cc#newcode141 sync/engine/net/server_connection_manager.cc:141: if (connection_) { ...
7 years, 3 months ago (2013-09-05 15:35:27 UTC) #3
akalin
threading lgtm, I don't think there's a general-purpose thing that can do what CancellableSignal does. ...
7 years, 3 months ago (2013-09-05 16:06:35 UTC) #4
rlarocque
Patch updated. https://codereview.chromium.org/23189021/diff/13001/chrome/browser/sync/glue/sync_backend_host.h File chrome/browser/sync/glue/sync_backend_host.h (right): https://codereview.chromium.org/23189021/diff/13001/chrome/browser/sync/glue/sync_backend_host.h#newcode367 chrome/browser/sync/glue/sync_backend_host.h:367: syncer::CancellationSignal* cancellation_signal; On 2013/09/05 16:06:35, akalin wrote: ...
7 years, 3 months ago (2013-09-05 22:37:06 UTC) #5
tim (not reviewing)
https://codereview.chromium.org/23189021/diff/33001/sync/engine/net/server_connection_manager.cc File sync/engine/net/server_connection_manager.cc (right): https://codereview.chromium.org/23189021/diff/33001/sync/engine/net/server_connection_manager.cc#newcode132 sync/engine/net/server_connection_manager.cc:132: // We should be registered iff connection_.get() != NULL. ...
7 years, 3 months ago (2013-09-06 21:47:34 UTC) #6
rlarocque
Patch updated. PTAL. https://codereview.chromium.org/23189021/diff/33001/sync/engine/net/server_connection_manager.cc File sync/engine/net/server_connection_manager.cc (right): https://codereview.chromium.org/23189021/diff/33001/sync/engine/net/server_connection_manager.cc#newcode132 sync/engine/net/server_connection_manager.cc:132: // We should be registered iff ...
7 years, 3 months ago (2013-09-06 22:42:53 UTC) #7
tim (not reviewing)
mostly looks good although I still think the test comment stands. https://codereview.chromium.org/23189021/diff/33001/sync/internal_api/public/base/cancelation_signal.cc File sync/internal_api/public/base/cancelation_signal.cc (right): ...
7 years, 3 months ago (2013-09-06 23:17:41 UTC) #8
rlarocque
Added tests. PTAL. https://codereview.chromium.org/23189021/diff/33001/sync/internal_api/public/base/cancelation_signal.cc File sync/internal_api/public/base/cancelation_signal.cc (right): https://codereview.chromium.org/23189021/diff/33001/sync/internal_api/public/base/cancelation_signal.cc#newcode48 sync/internal_api/public/base/cancelation_signal.cc:48: handler_->OnStopRequested(); On 2013/09/06 23:17:41, timsteele wrote: ...
7 years, 3 months ago (2013-09-09 18:06:58 UTC) #9
tim (not reviewing)
https://codereview.chromium.org/23189021/diff/68001/sync/internal_api/public/base/cancelation_signal_unittest.cc File sync/internal_api/public/base/cancelation_signal_unittest.cc (right): https://codereview.chromium.org/23189021/diff/68001/sync/internal_api/public/base/cancelation_signal_unittest.cc#newcode105 sync/internal_api/public/base/cancelation_signal_unittest.cc:105: BlockingTask blocking_task_; I don't see anything ever call event_.Reset ...
7 years, 3 months ago (2013-09-09 18:46:34 UTC) #10
tim (not reviewing)
On 2013/09/09 18:46:34, timsteele wrote: > https://codereview.chromium.org/23189021/diff/68001/sync/internal_api/public/base/cancelation_signal_unittest.cc > File sync/internal_api/public/base/cancelation_signal_unittest.cc (right): > > https://codereview.chromium.org/23189021/diff/68001/sync/internal_api/public/base/cancelation_signal_unittest.cc#newcode105 > ...
7 years, 3 months ago (2013-09-09 19:13:59 UTC) #11
tim (not reviewing)
LGTM
7 years, 3 months ago (2013-09-09 19:37:39 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rlarocque@chromium.org/23189021/68001
7 years, 3 months ago (2013-09-09 19:54:50 UTC) #13
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build on ...
7 years, 3 months ago (2013-09-09 20:20:34 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rlarocque@chromium.org/23189021/88001
7 years, 3 months ago (2013-09-09 21:10:04 UTC) #15
commit-bot: I haz the power
7 years, 3 months ago (2013-09-10 00:39:55 UTC) #16
Message was sent while issue was closed.
Change committed as 222154

Powered by Google App Engine
This is Rietveld 408576698