New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 605663 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug



Sign in to add a comment

QuotaManagerProxy::GetUsageAndQuota not running its callback

Project Member Reported by jkarlin@chromium.org, Apr 21 2016

Issue description

Steps to reproduce:

1. Open an incognito tab
2. Go to https://events.google.com/io2016/
3. Wait for "Caching Complete!" toast

If you don't see the toast (say 1 in 10 times or so), then you've reproduced the problem. The ServiceWorker is stuck in the installing step, waiting for a cache.put() to resolve.

Printfs show that the put operation isn't resolving because the call to quota_manager_proxy_->GetUsageAndQuota isn't running its callback. It seems the QuotaManager gets stuck and none of the subsequent calls work. 

This started happening with M50, which is the first stable release in which CacheStorage checks quota in Put operations. See https://codereview.chromium.org/1636613002/

I've only seen this happen in incognito windows (as it's easier to test there), not sure if it happens in non-incognito. But it's verified to happen on OSX and Linux desktop.

 
The crash I got on https://bugs.chromium.org/p/chromium/issues/detail?id=605755 migth be related. I had the devtools inspector open, the SW was stuck in INSTALLING, and then the crash happened moments later. I was not in an incognito window.
Thanks Eric. That could be related. One thing that GetUsageAndQuota would do is query CacheStorage for its size which would lead to a memory cache operation in incognito mode. Perhaps that's what is failing to return. 
Components: -Blink>Storage>Quota Blink>Storage>CacheStorage
Labels: OS-All
Owner: jkarlin@chromium.org
Status: Assigned (was: Unconfirmed)
Narrowed it down to CacheStorage::Size not running its callback so moving it over to Blink>Storage>CacheStorage.
Status: Started (was: Assigned)
Here is what's happening:

1. Cache A is opened
2. Cache B is opened
3. Cache A::Put is called and blocks on initialization
4. Cache B::Put is called and blocks on initialization
5. Cache A initializes and calls QuotaManager::GetUsageAndQuota()
6. Size() gets called on Cache A and Cache B for GetUsageAndQuota
7. Cache A runs its size immediately because it's initialized
8. Cache B blocks Size until initialization completes, putting it behind the Put operation in the queue
9. Cache B initializes, and starts the next operation, B::Put
10. B::Put calls QuotaManager::GetUsageAndQuota, which is blocked on the first call to GetUsageAndQuota, which is waiting for the pending B::Size() operation which is next in queue but won't run until B::Put finishes
11. Deadlock

I really really dislike that CacheStorageCache::Put() calls out to another class that needs to run a CacheStorageCache operation. I'm open to suggestions as to how that could be avoided.

In the meanwhile, I've created https://codereview.chromium.org/1916473002 which runs pending Size() operations immediately after initialization, before scheduled operations. It makes sense and it works, but it makes me sad.
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8b14d719f48c5d2b1f2f61fec372ee01e5f938a8

commit 8b14d719f48c5d2b1f2f61fec372ee01e5f938a8
Author: jkarlin <jkarlin@chromium.org>
Date: Fri Apr 22 18:52:02 2016

[CacheStorage] Prioritize Size operations over other scheduled operations

This CL runs pending Size() operations immediately after backend
initialization instead of in scheduler order. This is because
scheduled operations might depend on the QuotaManager which may call
Size() mid-operation.

BUG= 605663 

Review URL: https://codereview.chromium.org/1916473002

Cr-Commit-Position: refs/heads/master@{#389184}

[modify] https://crrev.com/8b14d719f48c5d2b1f2f61fec372ee01e5f938a8/content/browser/cache_storage/cache_storage_cache.cc
[modify] https://crrev.com/8b14d719f48c5d2b1f2f61fec372ee01e5f938a8/content/browser/cache_storage/cache_storage_cache.h
[modify] https://crrev.com/8b14d719f48c5d2b1f2f61fec372ee01e5f938a8/content/browser/cache_storage/cache_storage_cache_unittest.cc

Labels: Merge-Request-51
Will let this run over the weekend and hope to merge on Monday (4/25) assuming things look good.

Comment 7 by tin...@google.com, Apr 23 2016

Labels: -Merge-Request-51 Merge-Approved-51 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M51 (branch: 2704)
Project Member

Comment 8 by bugdroid1@chromium.org, Apr 25 2016

Labels: -merge-approved-51 merge-merged-2704
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ee24d582b9e8cf99fdab2efc28dd6b39021540ca

commit ee24d582b9e8cf99fdab2efc28dd6b39021540ca
Author: Josh Karlin <jkarlin@chromium.org>
Date: Mon Apr 25 11:09:03 2016

[CacheStorage] Prioritize Size operations over other scheduled operations

This CL runs pending Size() operations immediately after backend
initialization instead of in scheduler order. This is because
scheduled operations might depend on the QuotaManager which may call
Size() mid-operation.

BUG= 605663 

Review URL: https://codereview.chromium.org/1916473002

Cr-Commit-Position: refs/heads/master@{#389184}
(cherry picked from commit 8b14d719f48c5d2b1f2f61fec372ee01e5f938a8)

Review URL: https://codereview.chromium.org/1915893002 .

Cr-Commit-Position: refs/branch-heads/2704@{#212}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/ee24d582b9e8cf99fdab2efc28dd6b39021540ca/content/browser/cache_storage/cache_storage_cache.cc
[modify] https://crrev.com/ee24d582b9e8cf99fdab2efc28dd6b39021540ca/content/browser/cache_storage/cache_storage_cache.h
[modify] https://crrev.com/ee24d582b9e8cf99fdab2efc28dd6b39021540ca/content/browser/cache_storage/cache_storage_cache_unittest.cc

Labels: Merge-Request-50
Requesting stable merge. This bug can cause pages to fail to load due to CacheStorage locking up. No problems found in the dev and canary bake in.

Comment 10 by tin...@google.com, Apr 29 2016

Labels: -Merge-Request-50 Merge-Review-50 Hotlist-Merge-Review
[Automated comment] Request affecting a post-stable build (M50), manual review required.
Cc: tinazh@chromium.org
Labels: -Merge-Review-50 Merge-Approved-50
Approving merge to M50 branch 2661, based on comment #9. Please merge before 1:00 PM PST on Monday (05/09) so we can take it for next week stable refresh.
Project Member

Comment 12 by bugdroid1@chromium.org, May 6 2016

Labels: -merge-approved-50 merge-merged-2661
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e09345bdc7a8dccf7baa38a3959d7ba7380fc54c

commit e09345bdc7a8dccf7baa38a3959d7ba7380fc54c
Author: Josh Karlin <jkarlin@chromium.org>
Date: Fri May 06 19:03:36 2016

[CacheStorage] Prioritize Size operations over other scheduled operations

This CL runs pending Size() operations immediately after backend
initialization instead of in scheduler order. This is because
scheduled operations might depend on the QuotaManager which may call
Size() mid-operation.

BUG= 605663 

Review URL: https://codereview.chromium.org/1916473002

Cr-Commit-Position: refs/heads/master@{#389184}
(cherry picked from commit 8b14d719f48c5d2b1f2f61fec372ee01e5f938a8)

Review URL: https://codereview.chromium.org/1957663004 .

Cr-Commit-Position: refs/branch-heads/2661@{#663}
Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081}

[modify] https://crrev.com/e09345bdc7a8dccf7baa38a3959d7ba7380fc54c/content/browser/cache_storage/cache_storage_cache.cc
[modify] https://crrev.com/e09345bdc7a8dccf7baa38a3959d7ba7380fc54c/content/browser/cache_storage/cache_storage_cache.h
[modify] https://crrev.com/e09345bdc7a8dccf7baa38a3959d7ba7380fc54c/content/browser/cache_storage/cache_storage_cache_unittest.cc

Status: Fixed (was: Started)
Labels: TE-Verified-M50 TE-Verified-50.0.2661.102
Tested the issue on Windows 7, Mac 10.11.4, Ubuntu 14.04 using 50.0.2661.102.Observed that "Caching Complete!" toast is seen. Please find attached screencast.

Marking it as TE-Verified.
605663.mp4
1.1 MB Download
Just for reference:

commit 8b14d719f48c5d2b1f2f61fec372ee01e5f938a8 was:
  initially in 52.0.2716.0
  merged to 50.0.2661.98 (as e09345bdc7a8dccf7baa38a3959d7ba7380fc54c)
  merged to 51.0.2704.27 (as ee24d582b9e8cf99fdab2efc28dd6b39021540ca)

(generated by "git find-releases")
Note that there is another way this hang can occur, see continued discussion in  issue 620713 .

Sign in to add a comment