Bug 235340 - Assertion is not acquired in network process when setting database journal mode
Summary: Assertion is not acquired in network process when setting database journal mode
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-18 16:19 PST by Sihui Liu
Modified: 2022-01-19 11:49 PST (History)
3 users (show)

See Also:


Attachments
Patch (1.33 KB, patch)
2022-01-18 16:25 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (1.45 KB, patch)
2022-01-18 22:29 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 Sihui Liu 2022-01-18 16:19:34 PST
...
Comment 1 Sihui Liu 2022-01-18 16:23:58 PST
An example trace when network process is killed for holding database lock:

Thread 3  Dispatch queue: WebResourceLoadStatisticsStore Process Data Queue
...
13  libsqlite3.dylib              	       0x1f666f8e0 sqlite3LockAndPrepare + 244 (/Library/Caches/com.apple.xbs/Sources/SQLite/derived_source/sqlite3.c:139474)
14  WebCore                       	       0x1e8b30858 WebCore::SQLiteDatabase::prepareStatement(WTF::ASCIILiteral) + 120 (/Library/Caches/com.apple.xbs/Sources/WebCore/Source/WebCore/./platform/sql/SQLiteDatabase.cpp:696)
15  WebCore                       	       0x1e8b30298 WebCore::SQLiteDatabase::open(WTF::String const&, WebCore::SQLiteDatabase::OpenMode) + 1776 (/Library/Caches/com.apple.xbs/Sources/WebCore/Source/WebCore/./platform/sql/SQLiteDatabase.cpp:228)
16  WebKit                        	       0x1e64953bc WebKit::DatabaseUtilities::openDatabaseAndCreateSchemaIfNecessary() + 148 (/Library/Caches/com.apple.xbs/Sources/WebKit/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp:92)
17  WebKit                        	       0x1e65296bc WTF::Detail::CallableWrapper<WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(WebKit::NetworkSession&, WTF::String const&, WebKit::ShouldIncludeLocalhost, WebCore::ResourceLoadStatistics::IsEphemeral)::$_33, void>::call() + 788 (/Library/Caches/com.apple.xbs/Sources/WebKit/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:341)
...
Comment 2 Radar WebKit Bug Importer 2022-01-18 16:24:11 PST
<rdar://problem/87741289>
Comment 3 Sihui Liu 2022-01-18 16:25:11 PST
Created attachment 449446 [details]
Patch
Comment 4 Darin Adler 2022-01-18 18:07:16 PST
Comment on attachment 449446 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        Assertion is not acquired in network process when setting database journal mode

What is the effect of not acquiring this assertion? Is there a test failing because of this mistake>
Comment 5 Sihui Liu 2022-01-18 22:26:43 PST
(In reply to Darin Adler from comment #4)
> Comment on attachment 449446 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=449446&action=review
> 
> > Source/WebCore/ChangeLog:3
> > +        Assertion is not acquired in network process when setting database journal mode
> 
> What is the effect of not acquiring this assertion? Is there a test failing
> because of this mistake>

Assertion is needed for keeping process active. If assertion is not held, process can be suspended.
When a process is suspended and it's holding file lock, it will get killed by running boardd (to ensure file lock is released).
So we need to hold assertion when doing database activities that requires file lock.
There is no test (since it involves daemons), but we see network process gets killed with trace I pasted above. More traces in rdar://82412733.
Comment 6 Sihui Liu 2022-01-18 22:29:11 PST
Created attachment 449464 [details]
Patch
Comment 7 Chris Dumez 2022-01-19 07:19:09 PST
Comment on attachment 449464 [details]
Patch

r=me
Comment 8 EWS 2022-01-19 11:49:33 PST
Committed r288223 (246183@main): <https://commits.webkit.org/246183@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449464 [details].