diff --git a/Pods b/Pods index 73ff9dcbe7..148f33d0a8 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 73ff9dcbe7dbe67365d85370c51973260bdb2ff9 +Subproject commit 148f33d0a8b93f784c3b247dc22315ccaa90b58c diff --git a/SignalMessaging/environment/AppSetup.m b/SignalMessaging/environment/AppSetup.m index 5ba2d360f9..c4864b10d1 100644 --- a/SignalMessaging/environment/AppSetup.m +++ b/SignalMessaging/environment/AppSetup.m @@ -177,6 +177,8 @@ NS_ASSUME_NONNULL_BEGIN dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ if (AppSetup.shouldTruncateGrdbWal) { + // Try to truncate GRDB WAL before any readers or writers are + // active. NSError *_Nullable error; [databaseStorage.grdbStorage syncTruncatingCheckpointAndReturnError:&error]; if (error != nil) { diff --git a/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift b/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift index 97db573400..67cb0201e9 100644 --- a/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift +++ b/SignalMessaging/environment/migrations/YDBToGRDBMigration.swift @@ -147,8 +147,6 @@ extension YDBToGRDBMigration { try self.migrate(migratorGroups: migratorGroups) - try! storage.syncTruncatingCheckpoint() - removeYdb() let migrationDuration = abs(startDate.timeIntervalSinceNow) diff --git a/SignalServiceKit/src/Storage/Database/Snapshots/UIDatabaseSnapshot.swift b/SignalServiceKit/src/Storage/Database/Snapshots/UIDatabaseSnapshot.swift index 23f475d93f..214867adb9 100644 --- a/SignalServiceKit/src/Storage/Database/Snapshots/UIDatabaseSnapshot.swift +++ b/SignalServiceKit/src/Storage/Database/Snapshots/UIDatabaseSnapshot.swift @@ -31,6 +31,33 @@ enum DatabaseObserverError: Error { case changeTooLarge } +@objc +public class AtomicBool: NSObject { + private var value: Bool + + @objc + public required init(_ value: Bool) { + self.value = value + } + + // All instances can share a single queue. + private static let serialQueue = DispatchQueue(label: "AtomicBool") + + @objc + public func get() -> Bool { + return AtomicBool.serialQueue.sync { + return self.value + } + } + + @objc + public func set(_ value: Bool) { + return AtomicBool.serialQueue.sync { + self.value = value + } + } +} + func AssertIsOnUIDatabaseObserverSerialQueue() { assert(UIDatabaseObserver.isOnUIDatabaseObserverSerialQueue) } @@ -220,8 +247,6 @@ extension UIDatabaseObserver: TransactionObserver { isRunningCheckpoint = true } - SDSDatabaseStorage.shared.logFileSizes() - let result = try GRDBDatabaseStorageAdapter.checkpointWal(db: db, mode: mode) Logger.info("walSizePages: \(result.walSizePages), pagesCheckpointed: \(result.pagesCheckpointed).") diff --git a/SignalServiceKit/src/Util/Atomics.swift b/SignalServiceKit/src/Util/Atomics.swift deleted file mode 100644 index df226127ac..0000000000 --- a/SignalServiceKit/src/Util/Atomics.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. -// - -import Foundation - -@objc -public class AtomicBool: NSObject { - private var value: Bool - - @objc - public required init(_ value: Bool) { - self.value = value - } - - // All instances can share a single queue. - private static let serialQueue = DispatchQueue(label: "AtomicBool") - - @objc - public func get() -> Bool { - return AtomicBool.serialQueue.sync { - return self.value - } - } - - @objc - public func set(_ value: Bool) { - return AtomicBool.serialQueue.sync { - self.value = value - } - } -}