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

Issue 1011333003: Fix races when the same bits are downloaded from 2 URLs. (Closed)

Created:
5 years, 9 months ago by qsr
Modified:
5 years, 9 months ago
CC:
mojo-reviews_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, darin (slow to review), ben+mojo_chromium.org, ojan
Base URL:
https://github.com/domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

Fix races when the same bits are downloaded from 2 URLs. Until now, we were saving downloaded file to the temporary directory with a name being the hash of the file content. It means there is a race when the same content is downloaded from 2 different URLs. To fix this, we now create an intermediary directory that is the hash of the URL. Also, because this is only needed for debugging with gdb, and this is inefficient in term of both CPU and storage (we do not know when to delete the temporary directory), we control this with a command line flag. R=ncbray@chromium.org, eseidel@chromium.org BUG=https://github.com/domokit/mojo/issues/61 Committed: https://chromium.googlesource.com/external/mojo/+/690a515b6e5f7a2224d7dbbdf74a8e2b6ceaf1c2

Patch Set 1 #

Total comments: 6

Patch Set 2 : Follow review #

Patch Set 3 : Follow review #

Unified diffs Side-by-side diffs Delta from patch set Stats (+54 lines, -22 lines) Patch
M mojo/tools/data/apptests View 2 chunks +3 lines, -6 lines 0 comments Download
M shell/application_manager/network_fetcher.h View 1 chunk +2 lines, -1 line 0 comments Download
M shell/application_manager/network_fetcher.cc View 1 2 4 chunks +35 lines, -12 lines 0 comments Download
M shell/desktop/mojo_main.cc View 1 1 chunk +1 line, -0 lines 0 comments Download
M shell/switches.h View 1 chunk +1 line, -0 lines 0 comments Download
M shell/switches.cc View 1 3 chunks +11 lines, -3 lines 0 comments Download
M sky/tools/skydb View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
qsr
5 years, 9 months ago (2015-03-19 11:05:40 UTC) #1
Nick Bray (chromium)
Thanks for picking this up, I've been on a 2-day interview bender. LGTM in light ...
5 years, 9 months ago (2015-03-19 17:45:20 UTC) #2
Aaron Boodman
Why not just use the app's identity (e.g., sha1(app-url-minus-querystring)) as the name to save under ...
5 years, 9 months ago (2015-03-20 00:29:55 UTC) #3
Nick Bray (chromium)
On 2015/03/20 00:29:55, Aaron Boodman wrote: > Why not just use the app's identity (e.g., ...
5 years, 9 months ago (2015-03-20 02:45:07 UTC) #4
qsr
On 2015/03/19 17:45:20, Nick Bray (chromium) wrote: > Thanks for picking this up, I've been ...
5 years, 9 months ago (2015-03-20 10:19:47 UTC) #5
qsr
https://codereview.chromium.org/1011333003/diff/1/shell/application_manager/network_fetcher.cc File shell/application_manager/network_fetcher.cc (right): https://codereview.chromium.org/1011333003/diff/1/shell/application_manager/network_fetcher.cc#newcode131 shell/application_manager/network_fetcher.cc:131: crypto::SHA256HashString(url.spec()).data(), crypto::kSHA256Length); On 2015/03/19 17:45:20, Nick Bray (chromium) wrote: ...
5 years, 9 months ago (2015-03-20 11:50:49 UTC) #6
qsr
Committed patchset #3 (id:40001) manually as 690a515b6e5f7a2224d7dbbdf74a8e2b6ceaf1c2 (presubmit successful).
5 years, 9 months ago (2015-03-20 11:51:06 UTC) #7
Nick Bray (chromium)
On 2015/03/20 10:19:47, qsr wrote: > On 2015/03/19 17:45:20, Nick Bray (chromium) wrote: > > ...
5 years, 9 months ago (2015-03-20 17:22:19 UTC) #8
qsr
5 years, 9 months ago (2015-03-23 09:28:53 UTC) #9
Message was sent while issue was closed.
On 2015/03/20 17:22:19, Nick Bray (chromium) wrote:
> On 2015/03/20 10:19:47, qsr wrote:
> > On 2015/03/19 17:45:20, Nick Bray (chromium) wrote:
> > > Thanks for picking this up, I've been on a 2-day interview bender.
> > > 
> > > LGTM in light of time zone differences, but there also needs to be
comments
> > and
> > > commit message info about the badness that happens when you have two mojo
> apps
> > > sharing the same path on disk.  This is not a race, but a result of shared
> > > library loading semantics that most people don't know or think about. 
> Comment
> > > the crap out of this.  I do not want us forgetting it again.  You're
fixing
> > > multiple things but the commit message only mentions one.
> > 
> >  I don't understand this point. We should never be loading two mojo apps
from
> > the same path on disk (unless there is symbolic links, or hard links, and
none
> > of this is not the problem of the shell, as it cannot even detect that
> > reliably). An application identity is the end URL without the query string.
If
> > we have 2 URL that map to the same path on disk, they will be the same app,
> and
> > will only be loaded once.
> > 
> >  The issue was not that we were loading twice the same URL on disk, the
> problem
> > was that we were loading one app, while a second thread was writing the
file.
> 
> Please re-read the commit message from the original CL:
> https://codereview.chromium.org/1009003002/
> I can believe racy writes to the temp directory were a problem, but the issue
I
> cite in that CL was the root problem for pretty much all the flake we were
> seeing on the tree about a week ago.  I believe your change to stop DCHECKING
on
> MOJO_ABORT was treating a symptom of this problem.  That is where I started
> investigating.

 Interesting, I know dlopen was looking very hard not to load the same library
twice (to the point that using hard link doesn't work), so I was expecting it to
look at the inode of the library, not at the place on disk... It seems it does
both...

>  
> >  I don't think there is. See ApplicationManager::HandleFetchCallback. When
we
> > receive the content from the fetcher, the first thing we do is checking if
the
> > app is not already started, and connecting to it if that's the case.
> 
> Well, I think that almost works (but really should be commented more precisely
> than "around we go again".)  However, because there can still be two fetches
in
> flight for the same application (de-duping does not occur until after the
fetch
> has happened), doesn't that still allow the same file truncation problem? 
Just
> for the same URL, rather than for different URLs?

 You are right. Will have to fix this. Thanks.

Powered by Google App Engine
This is Rietveld 408576698