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

Issue 651063002: Deflake Simple Cache backend on Windows. (Closed)

Created:
6 years, 2 months ago by gavinp
Modified:
6 years, 1 month ago
Reviewers:
pasko, jkarlin, mmenke
CC:
chromium-reviews, cbentzel+watch_chromium.org, gavinp+disk_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Deflake Simple Cache backend on Windows. By taking a bit of care around opening files and deleting them, POSIX-like semantics are possible, and Simple Cache tests pass. R=gavinp@chromium.org BUG=None Committed: https://crrev.com/4b8931c7bea78530879a0e610be2ab0deb3b6384 Cr-Commit-Position: refs/heads/master@{#301784}

Patch Set 1 #

Patch Set 2 : try FLAG_SHARE_DELETE #

Patch Set 3 : now with renames #

Patch Set 4 : ordering & includes #

Patch Set 5 : append rite #

Patch Set 6 : add index file #

Total comments: 9

Patch Set 7 : remediate #

Total comments: 10

Patch Set 8 : remediate to review #

Patch Set 9 : C4800 #

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+103 lines, -30 lines) Patch
M net/disk_cache/backend_unittest.cc View 1 2 3 4 5 2 chunks +0 lines, -7 lines 0 comments Download
M net/disk_cache/entry_unittest.cc View 1 2 3 4 5 2 chunks +0 lines, -7 lines 0 comments Download
M net/disk_cache/simple/simple_index_file.cc View 1 2 3 4 5 6 7 chunks +22 lines, -9 lines 3 comments Download
M net/disk_cache/simple/simple_synchronous_entry.cc View 1 2 3 4 5 6 chunks +10 lines, -6 lines 0 comments Download
M net/disk_cache/simple/simple_util.h View 1 2 3 4 5 6 1 chunk +8 lines, -1 line 1 comment Download
A net/disk_cache/simple/simple_util_posix.cc View 1 2 3 4 5 6 1 chunk +17 lines, -0 lines 0 comments Download
A net/disk_cache/simple/simple_util_win.cc View 1 2 3 4 5 6 7 8 1 chunk +44 lines, -0 lines 5 comments Download
M net/net.gypi View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (5 generated)
gavinp
mmenke: PTAL jkarlin, pasko: FYI.
6 years, 1 month ago (2014-10-28 19:16:52 UTC) #3
mmenke
https://codereview.chromium.org/651063002/diff/120001/net/disk_cache/simple/simple_index_file.cc File net/disk_cache/simple/simple_index_file.cc (right): https://codereview.chromium.org/651063002/diff/120001/net/disk_cache/simple/simple_index_file.cc#newcode74 net/disk_cache/simple/simple_index_file.cc:74: File::FLAG_SHARE_DELETE); optional: Think it's much clearer that "File::FLAG_SHARE_DELETE" is ...
6 years, 1 month ago (2014-10-28 20:07:43 UTC) #4
gavinp
Thanks, Matt. Thank you for your review, I'm very excited about this issue landing. https://codereview.chromium.org/651063002/diff/120001/net/disk_cache/simple/simple_index_file.cc ...
6 years, 1 month ago (2014-10-28 23:09:40 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/651063002/140001
6 years, 1 month ago (2014-10-28 23:11:09 UTC) #7
commit-bot: I haz the power
No LGTM from a valid reviewer yet. Only full committers are accepted. Even if an ...
6 years, 1 month ago (2014-10-28 23:11:11 UTC) #9
mmenke
LGTM. Don't care about the others, but should remove the "we's" https://codereview.chromium.org/651063002/diff/120001/net/disk_cache/simple/simple_util_posix.cc File net/disk_cache/simple/simple_util_posix.cc (right): ...
6 years, 1 month ago (2014-10-28 23:58:37 UTC) #10
gavinp
Thanks for your review. I've removed the "we". https://codereview.chromium.org/651063002/diff/120001/net/disk_cache/simple/simple_util_posix.cc File net/disk_cache/simple/simple_util_posix.cc (right): https://codereview.chromium.org/651063002/diff/120001/net/disk_cache/simple/simple_util_posix.cc#newcode1 net/disk_cache/simple/simple_util_posix.cc:1: // ...
6 years, 1 month ago (2014-10-29 03:12:26 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/651063002/180001
6 years, 1 month ago (2014-10-29 03:38:21 UTC) #13
commit-bot: I haz the power
Committed patchset #9 (id:180001)
6 years, 1 month ago (2014-10-29 04:21:52 UTC) #14
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/4b8931c7bea78530879a0e610be2ab0deb3b6384 Cr-Commit-Position: refs/heads/master@{#301784}
6 years, 1 month ago (2014-10-29 04:22:40 UTC) #15
pasko
flyby LGTM with PHMU (please help me understand) https://codereview.chromium.org/651063002/diff/180001/net/disk_cache/simple/simple_index_file.cc File net/disk_cache/simple/simple_index_file.cc (right): https://codereview.chromium.org/651063002/diff/180001/net/disk_cache/simple/simple_index_file.cc#newcode362 net/disk_cache/simple/simple_index_file.cc:362: simple_util::SimpleCacheDeleteFile(index_filename); ...
6 years, 1 month ago (2014-10-29 13:01:02 UTC) #16
gavinp
Thanks for the drive by Egor. Since this already landed, I'll consider these TODOs next ...
6 years, 1 month ago (2014-11-20 15:43:03 UTC) #17
pasko
6 years, 1 month ago (2014-11-20 16:19:33 UTC) #18
Message was sent while issue was closed.
https://codereview.chromium.org/651063002/diff/180001/net/disk_cache/simple/s...
File net/disk_cache/simple/simple_index_file.cc (right):

https://codereview.chromium.org/651063002/diff/180001/net/disk_cache/simple/s...
net/disk_cache/simple/simple_index_file.cc:362:
simple_util::SimpleCacheDeleteFile(index_filename);
On 2014/11/20 15:43:03, gavinp wrote:
> On 2014/10/29 13:01:01, pasko wrote:
> > maybe a TODO: it seems it would be cleaner and faster just to
> overwrite+truncate
> > the index file with new contents than to move+delete+create+write.
> 
> Fair point; in this case I suppose we could zero the length; the replacement
> should happen later?

yes, truncate+overwrite should also work.

But on the other hand it's probably a moot point. As far as I can tell we flush
the index only twice during the lifetime of the browser process on desktop.

https://codereview.chromium.org/651063002/diff/180001/net/disk_cache/simple/s...
File net/disk_cache/simple/simple_util_win.cc (right):

https://codereview.chromium.org/651063002/diff/180001/net/disk_cache/simple/s...
net/disk_cache/simple/simple_util_win.cc:20: // create a new file with the same
name until the original file is actually
On 2014/11/20 15:43:03, gavinp wrote:
> On 2014/10/29 13:01:02, pasko wrote:
> > disclaimer: I don't know windows file APIs, can you please educate me a
> little?
> > 
> > By 'actually deleted' do you mean the windows file api should call us back
and
> > say that the file is deleted? Or maybe it does 'eventually delete' and never
> > reports back?
> 
> If a file is open and it is deleted, then all open handles will be marked as
> delete-on-close, and the actual deletion will not happen until the last handle
> to the file closes.

Got it.

> I don't know if there's a callback; my guess is that there
> is one with the filesystem observation API? Not sure.
> 
> > 
> > Are the move semantics the same regarding the eventual deletion? can it
happen
> > that we move, create, but the file is 'not actually moved yet' when we
attempt
> > to create?
> >
> 
> In theory, yes, since MoveFile is not considered a transacted operation, so we
> are being a bit loosey goosey. In practice, a MoveFile inside of the same
> directory is atomic on local filesystems, not necessarily on network mounts. 

Is this really true? I did not find any proofs of this, not even a marvellous
one.

Some ideas:
http://stackoverflow.com/questions/167414/is-an-atomic-file-rename-with-overw...

namely, when we sunset XP, we can use MoveFileTransacted (may not work on some
Windows Server flavors, I guess).

> > What part of FLAG_SHARE_DELETE semantics are used here? the The
file_unittest
> > checks only that you can FLAG_DELETE_ON_CLOSE with a file successfully when
it
> > was open in the same process with FLAG_SHARE_DELETE, but we are not using
> > FLAG_DELETE_ON_CLOSE here. Is it OK?
> 
> Yes, it's OK, perhaps I should add a test; deleting an open file through the
> filename while there's an open handle is the same as setting
> FLAG_DELETE_ON_CLOSE on an already open handle.

I like the idea to add this test. If we ever are approached with flakiness, we
can see if this test is also flaky, which may (or may not) suggest us the root
cause.

Powered by Google App Engine
This is Rietveld 408576698