Bug 237065 - [macOS] TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory is a flaky failure
Summary: [macOS] TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Website Storage (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-22 16:44 PST by Ryan Haddad
Modified: 2022-03-01 14:34 PST (History)
5 users (show)

See Also:


Attachments
Patch (4.54 KB, patch)
2022-02-23 23:27 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (6.56 KB, patch)
2022-02-25 10:34 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (6.61 KB, patch)
2022-02-25 19:58 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (9.10 KB, patch)
2022-02-27 23:06 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (9.28 KB, patch)
2022-02-28 16:45 PST, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Haddad 2022-02-22 16:44:22 PST
TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory, added with https://commits.webkit.org/247316@main, is a flaky failure on macOS bots

    TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory
        LEAK: 1 WebProcessPool
        
        /Volumes/Data/worker/monterey-debug/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:864
        Expected equality of these values:
          "testvalue"
          getNextMessage().body
            Which is: "[null]"


https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory
Comment 1 Radar WebKit Bug Importer 2022-02-22 16:44:35 PST
<rdar://problem/89324250>
Comment 2 Sihui Liu 2022-02-23 23:27:59 PST
Created attachment 453079 [details]
Patch
Comment 3 Sihui Liu 2022-02-25 10:34:32 PST
Created attachment 453229 [details]
Patch
Comment 4 Alexey Proskuryakov 2022-02-25 16:59:45 PST
Comment on attachment 453229 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453229&action=review

> Source/WebKit/NetworkProcess/NetworkProcess.cpp:264
>      // Make sure we flush all cookies to disk before exiting.

This comment should probably be omitted. Typically, we want comments to explain "why", not "what". This comment just explains what, and it's not even entirely accurate any more after this addition.

> Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp:89
> +        std::atexit(commitTransactionsAtExit);

Do we still have a boost to prevent suspension at this point?
Comment 5 Sihui Liu 2022-02-25 19:57:55 PST
Comment on attachment 453229 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453229&action=review

>> Source/WebKit/NetworkProcess/NetworkProcess.cpp:264
>>      // Make sure we flush all cookies to disk before exiting.
> 
> This comment should probably be omitted. Typically, we want comments to explain "why", not "what". This comment just explains what, and it's not even entirely accurate any more after this addition.

Sure, will remove.

>> Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp:89
>> +        std::atexit(commitTransactionsAtExit);
> 
> Do we still have a boost to prevent suspension at this point?

You mean to prevent process from being suspended by taking an assertion?
I am not sure if a process can get suspended when it is exiting, but if it can, the worst case seems to be the process getting killed and losing data in unfinished transactions, which sounds like a rare case.
Comment 6 Sihui Liu 2022-02-25 19:58:49 PST
Created attachment 453284 [details]
Patch for landing
Comment 7 EWS 2022-02-25 21:43:55 PST
Committed r290544 (247822@main): <https://commits.webkit.org/247822@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453284 [details].
Comment 8 Sihui Liu 2022-02-27 22:07:30 PST
Reopened as the test failure is not fixed.
Comment 9 Sihui Liu 2022-02-27 23:06:54 PST
Created attachment 453368 [details]
Patch
Comment 10 Darin Adler 2022-02-28 15:33:35 PST
Comment on attachment 453368 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453368&action=review

> Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:43
> +#include <wtf/WeakHashSet.h>

Should not need this in the header just to declare a function returning a reference to a WeakHashSet. Forward.h should suffice.

> Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:74
> +    static WeakHashSet<NetworkStorageManager>& allNetworkStorageManagers();

I suggest we publish a forEachNetworkStorageManager function for NetworkProcess.cpp to use instead of of publishing a read/write reference to a WeakHashSet; would be nice to keep the WeakHashSet as a hidden implementation detail of this class.
Comment 11 Sihui Liu 2022-02-28 16:42:46 PST
(In reply to Darin Adler from comment #10)
> Comment on attachment 453368 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=453368&action=review
> 
> > Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:43
> > +#include <wtf/WeakHashSet.h>
> 
> Should not need this in the header just to declare a function returning a
> reference to a WeakHashSet. Forward.h should suffice.
> 
> > Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:74
> > +    static WeakHashSet<NetworkStorageManager>& allNetworkStorageManagers();
> 
> I suggest we publish a forEachNetworkStorageManager function for
> NetworkProcess.cpp to use instead of of publishing a read/write reference to
> a WeakHashSet; would be nice to keep the WeakHashSet as a hidden
> implementation detail of this class.

Sure, will add NetworkStorageManager::forEach() and remove WeakHashSet.h.
Comment 12 Sihui Liu 2022-02-28 16:45:29 PST
Created attachment 453449 [details]
Patch for landing
Comment 13 Darin Adler 2022-02-28 17:35:15 PST
Comment on attachment 453449 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=453449&action=review

> Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:43
> +#include <wtf/WeakHashSet.h>

Please don’t add this include to this header.
Comment 14 EWS 2022-02-28 18:35:47 PST
Committed r290623 (247896@main): <https://commits.webkit.org/247896@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453449 [details].
Comment 15 Sihui Liu 2022-03-01 14:34:28 PST
Comment on attachment 453449 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=453449&action=review

>> Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h:43
>> +#include <wtf/WeakHashSet.h>
> 
> Please don’t add this include to this header.

Oops, I missed this. Removed in r290669.