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

Issue 2757193003: [Sync] Do not deadlock when joining sync thread with a pending HistoryModelWorker task. (Closed)

Created:
3 years, 9 months ago by fdoray
Modified:
3 years, 8 months ago
Reviewers:
maxbogue, brettw
CC:
chromium-reviews
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[Sync] Do not deadlock when joining sync thread with a pending HistoryModelWorker task. Currently, this scenario results in a deadlock: Thread Action Sync HistoryModelWorker::DoWorkAndWaitUntilDone Posts to the UI thread and waits. UI HistoryModelWorker::RequestStop UI Join the sync thread. Deadlock because the sync thread is waiting for a task to run on the UI thread. With this CL, RequestStop() unblocks DoWorkAndWaitUntilDone() on the sync thread when it is waiting for a UI task. This change is similar to https://codereview.chromium.org/2505913003 BUG=663600

Patch Set 1 #

Patch Set 2 : self-review #

Total comments: 12

Patch Set 3 : CR #

Patch Set 4 : self-review #

Patch Set 5 : self-review #

Patch Set 6 : self-review #

Patch Set 7 : self-review #

Total comments: 8

Patch Set 8 : CR #

Total comments: 2

Patch Set 9 : fix comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+278 lines, -62 lines) Patch
M components/history/core/browser/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M components/history/core/browser/history_model_worker.h View 1 2 3 4 5 6 7 3 chunks +23 lines, -0 lines 0 comments Download
M components/history/core/browser/history_model_worker.cc View 1 2 3 4 5 6 7 8 4 chunks +82 lines, -62 lines 0 comments Download
A components/history/core/browser/history_model_worker_unittest.cc View 3 1 chunk +172 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (10 generated)
fdoray
PTAL
3 years, 9 months ago (2017-03-20 14:50:44 UTC) #4
maxbogue
This is an unfortunate amount of state to have to track but I don't see ...
3 years, 9 months ago (2017-03-20 16:52:37 UTC) #5
fdoray
PTAnL I changed many things to address your comments and reduce complexity. https://codereview.chromium.org/2757193003/diff/20001/components/history/core/browser/history_model_worker.cc File components/history/core/browser/history_model_worker.cc ...
3 years, 9 months ago (2017-03-20 18:54:54 UTC) #10
maxbogue
Ah, interesting new approach. The key is that if the task has been posted to ...
3 years, 9 months ago (2017-03-20 19:55:50 UTC) #11
fdoray
PTAnL https://codereview.chromium.org/2757193003/diff/120001/components/history/core/browser/history_model_worker.cc File components/history/core/browser/history_model_worker.cc (right): https://codereview.chromium.org/2757193003/diff/120001/components/history/core/browser/history_model_worker.cc#newcode49 components/history/core/browser/history_model_worker.cc:49: const scoped_refptr<HistoryModelWorker> history_model_worker_; On 2017/03/20 19:55:50, maxbogue wrote: ...
3 years, 9 months ago (2017-03-21 17:21:31 UTC) #12
maxbogue
lgtm! https://codereview.chromium.org/2757193003/diff/140001/components/history/core/browser/history_model_worker.cc File components/history/core/browser/history_model_worker.cc (right): https://codereview.chromium.org/2757193003/diff/140001/components/history/core/browser/history_model_worker.cc#newcode88 components/history/core/browser/history_model_worker.cc:88: // UI DoWorkAndWaitUntilDoneImpl() Waits on |work_done_or_abandoned_| s/UI/Sync/, I ...
3 years, 9 months ago (2017-03-21 18:35:40 UTC) #13
fdoray
sky@: PTAL https://codereview.chromium.org/2757193003/diff/140001/components/history/core/browser/history_model_worker.cc File components/history/core/browser/history_model_worker.cc (right): https://codereview.chromium.org/2757193003/diff/140001/components/history/core/browser/history_model_worker.cc#newcode88 components/history/core/browser/history_model_worker.cc:88: // UI DoWorkAndWaitUntilDoneImpl() Waits on |work_done_or_abandoned_| On ...
3 years, 9 months ago (2017-03-22 12:25:04 UTC) #16
sky
sky->brettw
3 years, 9 months ago (2017-03-22 16:08:07 UTC) #18
brettw
3 years, 9 months ago (2017-03-23 22:26:23 UTC) #19
This class has gone to having kind of mish-mash of locked threadsafe variables
and non-threadsafe ones.

Can the threadsafe portion of this class's variables be segregated in some inner
class or something?

I'd also like the comment above the HistoryModelWorker declaration to have a
discussion on the threading model and protection guarantees of it.

Powered by Google App Engine
This is Rietveld 408576698