Register all database views asynchronously.

pull/1/head
Matthew Chen 7 years ago
parent b21f793756
commit aeeef43416

@ -7,8 +7,8 @@ def shared_pods
# OWS Pods
# pod 'SQLCipher', path: '../sqlcipher2'
pod 'SQLCipher', :git => 'https://github.com/sqlcipher/sqlcipher.git', :commit => 'd5c2bec'
pod 'YapDatabase/SQLCipher', path: '../YapDatabase'
# pod 'YapDatabase/SQLCipher', :git => 'https://github.com/WhisperSystems/YapDatabase.git', branch: 'release/unencryptedHeaders'
# pod 'YapDatabase/SQLCipher', path: '../YapDatabase'
pod 'YapDatabase/SQLCipher', :git => 'https://github.com/WhisperSystems/YapDatabase.git', branch: 'release/unencryptedHeaders'
pod 'SignalServiceKit', path: '.'
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git', branch: 'mkirk/framework-friendly'
#pod 'AxolotlKit', path: '../SignalProtocolKit'

@ -141,7 +141,7 @@ DEPENDENCIES:
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
- SQLCipher (from `https://github.com/sqlcipher/sqlcipher.git`, commit `d5c2bec`)
- SSZipArchive
- YapDatabase/SQLCipher (from `../YapDatabase`)
- YapDatabase/SQLCipher (from `https://github.com/WhisperSystems/YapDatabase.git`, branch `release/unencryptedHeaders`)
- YYImage
EXTERNAL SOURCES:
@ -167,7 +167,8 @@ EXTERNAL SOURCES:
:commit: d5c2bec
:git: https://github.com/sqlcipher/sqlcipher.git
YapDatabase:
:path: ../YapDatabase
:branch: release/unencryptedHeaders
:git: https://github.com/WhisperSystems/YapDatabase.git
CHECKOUT OPTIONS:
AxolotlKit:
@ -191,6 +192,9 @@ CHECKOUT OPTIONS:
SQLCipher:
:commit: d5c2bec
:git: https://github.com/sqlcipher/sqlcipher.git
YapDatabase:
:commit: c58c6176941275c13ffe6ad697223e0cc3432928
:git: https://github.com/WhisperSystems/YapDatabase.git
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
@ -217,6 +221,6 @@ SPEC CHECKSUMS:
YapDatabase: 299a32de9d350d37a9ac5b0532609d87d5d2a5de
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
PODFILE CHECKSUM: 6da9d13ffba2c3d0ae0a0d376b8881102f41395f
PODFILE CHECKSUM: 0d804514eb2db34b9874b653e543255d8c2f5751
COCOAPODS: 1.3.1

@ -45,9 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
[NSKeyedUnarchiver setClass:[OWSUserProfile class] forClassName:[OWSUserProfile collection]];
[NSKeyedUnarchiver setClass:[OWSDatabaseMigration class] forClassName:[OWSDatabaseMigration collection]];
[OWSStorage setupWithSafeBlockingMigrations:^{
[VersionMigrations runSafeBlockingMigrations];
}];
[OWSStorage setupStorage];
[[Environment current].contactsManager startObserving];
});
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#define RECENT_CALLS_DEFAULT_KEY @"RPRecentCallsDefaultKey"
@ -8,8 +8,6 @@
+ (void)performUpdateCheck;
+ (void)runSafeBlockingMigrations;
+ (BOOL)isVersion:(NSString *)thisVersionString
atLeast:(NSString *)openLowerBoundVersionString
andLessThan:(NSString *)closedUpperBoundVersionString;

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "VersionMigrations.h"
@ -82,12 +82,6 @@
[[[OWSDatabaseMigrationRunner alloc] initWithStorageManager:[TSStorageManager sharedManager]] runAllOutstanding];
}
+ (void)runSafeBlockingMigrations
{
[[[OWSDatabaseMigrationRunner alloc] initWithStorageManager:[TSStorageManager sharedManager]]
runSafeBlockingMigrations];
}
+ (BOOL)isVersion:(NSString *)thisVersionString
atLeast:(NSString *)openLowerBoundVersionString
andLessThan:(NSString *)closedUpperBoundVersionString

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@ -17,15 +17,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)runAllOutstanding;
/**
* Run any outstanding version migrations that are a) blocking and b) safe
* to be run before the environment and storage is completely configured.
*
* Specifically, these migrations should not depend on or affect the data
* of any database view.
*/
- (void)runSafeBlockingMigrations;
/**
* On new installations, no need to migrate anything.
*/

@ -42,19 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
];
}
// This should only include migrations which:
//
// a) Do read/write database transactions and therefore would block on the async database
// view registration.
// b) Will not affect any of the data used by the async database views.
- (NSArray<OWSDatabaseMigration *> *)safeBlockingMigrations
{
TSStorageManager *storageManager = TSStorageManager.sharedManager;
return @[
// [[OWS104CreateRecipientIdentities alloc] initWithStorageManager:storageManager],
];
}
- (void)assumeAllExistingMigrationsRun
{
for (OWSDatabaseMigration *migration in self.allMigrations) {
@ -63,11 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
}
}
- (void)runSafeBlockingMigrations
{
[self runMigrations:self.safeBlockingMigrations];
}
- (void)runAllOutstanding
{
[self runMigrations:self.allMigrations];

@ -46,15 +46,7 @@ extern NSString *const StorageIsReadyNotification;
// This object can be used to filter database notifications.
@property (nonatomic, readonly, nullable) id dbNotificationObject;
/**
* The safeBlockingMigrationsBlock block will
* run any outstanding version migrations that are a) blocking and b) safe
* to be run before the environment and storage is completely configured.
*
* Specifically, these migration should not depend on or affect the data
* of any database view.
*/
+ (void)setupWithSafeBlockingMigrations:(void (^_Nonnull)(void))safeBlockingMigrationsBlock;
+ (void)setupStorage;
+ (void)resetAllStorage;

@ -334,29 +334,19 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
];
}
+ (void)setupWithSafeBlockingMigrations:(void (^_Nonnull)(void))safeBlockingMigrationsBlock
+ (void)setupStorage
{
OWSAssert(safeBlockingMigrationsBlock);
for (OWSStorage *storage in self.allStorages) {
[storage runSyncRegistrations];
}
// Run the blocking migrations.
//
// These need to run _before_ the async registered database views or
// they will block on them, which (in the upgrade case) can block
// return of appDidFinishLaunching... which in term can cause the
// app to crash on launch.
safeBlockingMigrationsBlock();
for (OWSStorage *storage in self.allStorages) {
[storage runAsyncRegistrationsWithCompletion:^{
[self postRegistrationCompleteNotificationIfPossible];
}];
((OWSDatabase *)storage.database).registrationConnectionCached = nil;
((OWSDatabase *)storage.database).registrationConnectionCached = nil;
}];
}
}

@ -134,15 +134,6 @@ void runAsyncRegistrationsForStorage(OWSStorage *storage)
// Block until all async registrations are complete.
YapDatabaseConnection *dbConnection = self.registrationConnection;
OWSAssert(self.registrationConnection);
// [dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction * _Nonnull transaction) {
// OWSAssert(!self.areAsyncRegistrationsComplete);
//
// DDLogVerbose(@"%@ async registrations flushed.", self.logTag);
//
// self.areAsyncRegistrationsComplete = YES;
//
// completion();
// }];
[dbConnection flushTransactionsWithCompletionQueue:dispatch_get_main_queue()
completionBlock:^{
OWSAssert(!self.areAsyncRegistrationsComplete);

Loading…
Cancel
Save