- Revision
- 275301
- Author
- sihui_...@apple.com
- Date
- 2021-03-31 12:34:51 -0700 (Wed, 31 Mar 2021)
Log Message
Add logging in IndexedDB to help debug flaky quota tests
https://bugs.webkit.org/show_bug.cgi?id=223578
<rdar://problem/75956789>
Reviewed by Alexey Proskuryakov.
Source/WebCore:
With r274323, we know that the tests fail because of IndexedDB. IndexedDB data should be cleared between tests,
so let's add more logging to see what databases are left.
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::diskUsage):
* Modules/indexeddb/server/IDBServer.h:
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:
Source/WebKit:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::storageQuotaManager):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (275300 => 275301)
--- trunk/Source/WebCore/ChangeLog 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebCore/ChangeLog 2021-03-31 19:34:51 UTC (rev 275301)
@@ -1,3 +1,21 @@
+2021-03-31 Sihui Liu <sihui_...@apple.com>
+
+ Add logging in IndexedDB to help debug flaky quota tests
+ https://bugs.webkit.org/show_bug.cgi?id=223578
+ <rdar://problem/75956789>
+
+ Reviewed by Alexey Proskuryakov.
+
+ With r274323, we know that the tests fail because of IndexedDB. IndexedDB data should be cleared between tests,
+ so let's add more logging to see what databases are left.
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::diskUsage):
+ * Modules/indexeddb/server/IDBServer.h:
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
2021-03-31 Alex Christensen <achristen...@webkit.org>
Add deprecation macros.
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (275300 => 275301)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2021-03-31 19:34:51 UTC (rev 275301)
@@ -758,13 +758,14 @@
return result;
}
-uint64_t IDBServer::diskUsage(const String& rootDirectory, const ClientOrigin& origin)
+uint64_t IDBServer::diskUsage(const String& rootDirectory, const ClientOrigin& origin, StorageQuotaManager::ShouldPrintUsageDetail shouldPrintUsageDetail)
{
ASSERT(!isMainThread());
auto oldVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, rootDirectory, "v0"_str);
auto newVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, rootDirectory, "v1"_str);
- return SQLiteIDBBackingStore::databasesSizeForDirectory(oldVersionOriginDirectory) + SQLiteIDBBackingStore::databasesSizeForDirectory(newVersionOriginDirectory);
+ bool shouldPrintUsageDetailForDirectory = shouldPrintUsageDetail == StorageQuotaManager::ShouldPrintUsageDetail::Yes;
+ return SQLiteIDBBackingStore::databasesSizeForDirectory(oldVersionOriginDirectory, shouldPrintUsageDetailForDirectory) + SQLiteIDBBackingStore::databasesSizeForDirectory(newVersionOriginDirectory, shouldPrintUsageDetailForDirectory);
}
void IDBServer::upgradeFilesIfNecessary()
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (275300 => 275301)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2021-03-31 19:34:51 UTC (rev 275301)
@@ -106,7 +106,7 @@
WEBCORE_EXPORT void renameOrigin(const WebCore::SecurityOriginData&, const WebCore::SecurityOriginData&);
StorageQuotaManager::Decision requestSpace(const ClientOrigin&, uint64_t taskSize);
- WEBCORE_EXPORT static uint64_t diskUsage(const String& rootDirectory, const ClientOrigin&);
+ WEBCORE_EXPORT static uint64_t diskUsage(const String& rootDirectory, const ClientOrigin&, StorageQuotaManager::ShouldPrintUsageDetail);
WEBCORE_EXPORT void stopDatabaseActivitiesOnMainThread();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (275300 => 275301)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2021-03-31 19:34:51 UTC (rev 275301)
@@ -1265,12 +1265,19 @@
return IDBError { };
}
-uint64_t SQLiteIDBBackingStore::databasesSizeForDirectory(const String& directory)
+uint64_t SQLiteIDBBackingStore::databasesSizeForDirectory(const String& directory, bool shouldPrintUsageDetail)
{
uint64_t diskUsage = 0;
for (auto& dbDirectory : FileSystem::listDirectory(directory, "*")) {
- for (auto& file : FileSystem::listDirectory(dbDirectory, "*.sqlite3"_s))
- diskUsage += SQLiteFileSystem::getDatabaseFileSize(file);
+ for (auto& file : FileSystem::listDirectory(dbDirectory, "*.sqlite3"_s)) {
+ auto fileSize = SQLiteFileSystem::getDatabaseFileSize(file);
+ diskUsage += fileSize;
+ if (shouldPrintUsageDetail) {
+ auto databaseNameAndVersion = databaseNameAndVersionFromFile(file);
+ String databaseName = databaseNameAndVersion ? databaseNameAndVersion->name : "[UNKNOWN]";
+ WTFLogAlways("SQLiteIDBBackingStore::databasesSizeForDirectory filePath='%s', database='%s', size=%" PRIu64, file.utf8().data(), databaseName.utf8().data(), fileSize);
+ }
+ }
}
return diskUsage;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (275300 => 275301)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2021-03-31 19:34:51 UTC (rev 275301)
@@ -95,7 +95,7 @@
IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);
- static uint64_t databasesSizeForDirectory(const String& directory);
+ static uint64_t databasesSizeForDirectory(const String& directory, bool shouldPrintUsageDetail = false);
String databaseDirectory() const { return m_databaseDirectory; };
static String fullDatabasePathForDirectory(const String&);
Modified: trunk/Source/WebKit/ChangeLog (275300 => 275301)
--- trunk/Source/WebKit/ChangeLog 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebKit/ChangeLog 2021-03-31 19:34:51 UTC (rev 275301)
@@ -1,3 +1,14 @@
+2021-03-31 Sihui Liu <sihui_...@apple.com>
+
+ Add logging in IndexedDB to help debug flaky quota tests
+ https://bugs.webkit.org/show_bug.cgi?id=223578
+ <rdar://problem/75956789>
+
+ Reviewed by Alexey Proskuryakov.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::storageQuotaManager):
+
2021-03-31 Alex Christensen <achristen...@webkit.org>
Add deprecation macros.
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (275300 => 275301)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-03-31 19:25:22 UTC (rev 275300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-03-31 19:34:51 UTC (rev 275301)
@@ -2517,14 +2517,14 @@
return nullptr;
String idbRootPath = sessionStorageQuotaManager->idbRootPath();
- StorageQuotaManager::UsageGetter usageGetter = [cacheRootPath = sessionStorageQuotaManager->cacheRootPath().isolatedCopy(), idbRootPath = idbRootPath.isolatedCopy(), origin = origin.isolatedCopy()](StorageQuotaManager::ShouldPrintUsageDetail shouldPrintusageDetail) {
+ StorageQuotaManager::UsageGetter usageGetter = [cacheRootPath = sessionStorageQuotaManager->cacheRootPath().isolatedCopy(), idbRootPath = idbRootPath.isolatedCopy(), origin = origin.isolatedCopy()](StorageQuotaManager::ShouldPrintUsageDetail shouldPrintUsageDetail) {
ASSERT(!isMainRunLoop());
uint64_t cacheUsage = CacheStorage::Engine::diskUsage(cacheRootPath, origin);
- uint64_t usage = cacheUsage + IDBServer::IDBServer::diskUsage(idbRootPath, origin);
+ uint64_t usage = cacheUsage + IDBServer::IDBServer::diskUsage(idbRootPath, origin, shouldPrintUsageDetail);
- if (shouldPrintusageDetail == StorageQuotaManager::ShouldPrintUsageDetail::Yes)
- WTFLogAlways("StorageQuotaManager::UsageGetter Cache usage %" PRIu64 ", IDB usage %" PRIu64, cacheUsage, usage);
+ if (shouldPrintUsageDetail == StorageQuotaManager::ShouldPrintUsageDetail::Yes)
+ WTFLogAlways("StorageQuotaManager::UsageGetter Cache usage %" PRIu64 ", IDB usage %" PRIu64, cacheUsage, usage - cacheUsage);
return usage;
};