Commit Graph

25475 Commits

Author SHA1 Message Date
Matthew Chen
aec22a4714 "Bump build to 5.21.3.1." 2021-10-04 09:57:09 -03:00
Matthew Chen
821c1c9638 "Feature flags for .production." 2021-10-04 09:57:06 -03:00
Matthew Chen
dd9b558ae9 Merge branch 'mlin/PR/DynamicDatabaseLocations' into release/5.21.3 2021-10-04 09:53:55 -03:00
Michelle Linington
e1241eef76 Fix database path KVO 2021-10-04 09:53:37 -03:00
Michelle Linington
e8d7e7b930 Additional logging 2021-10-04 09:53:37 -03:00
Michelle Linington
6f4d3ea56a Remove debug log messages and lint 2021-10-04 09:53:37 -03:00
Michelle Linington
8446ab4069 Minor changes to folder selection and restoration cleanup 2021-10-04 09:53:36 -03:00
Michelle Linington
3b6fa704f1 Three part version numbers need lexicographic ordering 2021-10-04 09:53:36 -03:00
Michelle Linington
686375c447 Add CI phase to select a minimum Xcode version
This change uses a throwing computed variable which was added in Swift
5.5 and requires Xcode 13 to compile.

The default Xcode on current macOS 11 image is still 12.5.1 and won't be
updated until later this month. The newer Xcode is available on these
machines, but until October 18th we need to select it manually.
https://github.com/actions/virtual-environments/issues/4180
2021-10-04 09:53:36 -03:00
Michelle Linington
417c135fc9 Lint 2021-10-04 09:53:36 -03:00
Michelle Linington
25740a25ed Wait until new database has opened before finalizing 2021-10-04 09:53:36 -03:00
Michelle Linington
85bdc19dea Better handling of KVO unregistration 2021-10-04 09:53:36 -03:00
Michelle Linington
738a4aae44 Remove ability to open database in other directory modes
This is unsafe in a cross-process world
2021-10-04 09:53:36 -03:00
Michelle Linington
ccf9383533 Improvements to database swap flow
Added a bunch of comments clarifying the database swap requirements.
Also, removed the baseDir parameter from GRDBDatabaseStorageAdapter.
2021-10-04 09:53:36 -03:00
Michelle Linington
fdc983519a Dynaically update database location at runtime
Fixes an issue where users were no longer receiving messages after
restoration. During restoration, the restoring device copies the
transferred database files to a special "hotswap" directory since we
don't want to overwrite our currently in-use database. Once finished, it
re-opens the database pointing to our hotswap directory. It would then
move the hotswap database to its primary location on the next app
launch.

The problem here is our extensions don't know how to read the hotswap
directory. Even if we added that capability, it's going to be tricky to
coordinate which database they read and when as the main app shuffles
files around.

This fix adjusts our restoration flow. Instead of having a special
"primary" and "hotswap" directory that we need to fix up on the next
launch, we instead record a UserDefaults entry that points to our
current database directory.

Once transfer has completed, the main app only needs to update the
current database directory in UserDefaults. No post-launch swapping
needs to occur.

Extensions will listen for updates to this database location by
registering KVO on NSUserDefaults.

This change also adjusts the restoration flow to break it up into
discrete stages. The motivation here is we need to make sure that a
partial restoration doesn't put the extensions in an inconsistent state.
2021-10-04 09:53:35 -03:00
Matthew Chen
23aace02c4 Merge branch 'mlin/PR/CallingFix' into release/5.21.3 2021-10-04 09:47:19 -03:00
Michelle Linington
187c866c2e Fix early rings 2021-10-03 17:30:33 -07:00
Michelle Linington
42ec564676 "Bump build to 5.21.3.0." (Internal) 2021-10-01 13:10:06 -07:00
Michelle Linington
4d3cff87c5 "Feature flags for .qa." 2021-10-01 13:09:54 -07:00
Matthew Chen
891a4638bd "Bump build to 5.21.2.5." (Beta) 2021-09-30 23:39:37 -03:00
Matthew Chen
7c9b984949 "Feature flags for .beta." 2021-09-30 23:39:34 -03:00
Matthew Chen
6989ba988a "Bump build to 5.21.2.4." 2021-09-30 23:39:28 -03:00
Matthew Chen
b7877b21f4 "Feature flags for .production." 2021-09-30 23:39:26 -03:00
Michelle Linington
cd218a596d Merge branch 'mlin/PR/RepeatAckStarvation' into release/5.21.2 2021-09-30 19:38:37 -07:00
Michelle Linington
c2cd2cd4c6 PR Feedback 2021-09-30 19:38:20 -07:00
Michelle Linington
ad080c4c14 Filter out duplicate pending acks
Seeing reports of long processing delays in the NSE. We can fetch
messages faster than they can be acked. This backs up our ack queue with
a bunch of repeat work, which means we re-fetch the same envelopes over
and over, which fills the ack queue with more repeat work.
2021-09-30 19:38:20 -07:00
Matthew Chen
bfc7351ab4 Elaborate logging around NSE message processing. 2021-09-30 23:24:47 -03:00
Matthew Chen
ffbb13c47d Elaborate logging around NSE message processing. 2021-09-30 20:37:15 -03:00
Matthew Chen
bb72128d3c "Bump build to 5.21.2.3." (Beta) 2021-09-30 17:18:56 -03:00
Matthew Chen
0e5ce66f6f "Feature flags for .beta." 2021-09-30 17:18:54 -03:00
Matthew Chen
a994989e82 "Bump build to 5.21.2.2." 2021-09-30 17:18:48 -03:00
Matthew Chen
cb782ca989 "Feature flags for .production." 2021-09-30 17:18:44 -03:00
Michelle Linington
75af0c570d Merge branch 'mlin/PR/SchemaMigrationCrash' into release/5.21.2 2021-09-30 13:01:06 -07:00
Michelle Linington
bcb7eddb63 Fix issue with data migrations after a schema change
We're seeing crashes during this data migration step. We fail to init
the OWSUserProfile from the Row result returned from the SQLite fetch
request. It's likely we're indexing into an out-of-bounds index on Row.
(Row._checkIndex is inlined so we can't be sure)

GRDB caches the sqlite3_column_count during Row.init and uses that to
determine if a subscript access is out-of-bounds. From what I can tell
in an amateur reading of sqlite3.c, that just pulls the nResColumn from
the prepared statement. SQLite will determine the number of result
columns during statement prep, but the column count can change if the
table schema changes:

> If the database schema changes, instead of returning SQLITE_SCHEMA as
  it always used to do, sqlite3_step() will automatically recompile the
  SQL statement and try to run it again. As many as
  SQLITE_MAX_SCHEMA_RETRY retries will occur before sqlite3_step() gives
  up and returns an error.

We're nesting a deferred read transaction inside of our data migration's
immediate transaction. This read is using a different sqlite connection
that the connection performing our migrations. So its understanding of
the schema is stale and because it's in a deferred transaction it won't
figure this out until we call _step().

Once we call _step(), sqlite will realize that the table schema has
changed and recompile the prepared statement while opening the
deferred transaction. After this, the sqlite_column_count is correct.
But Row still has the incorrect value cached from before the schema was
resolved.

So by the time we try and init our OWSUserProfile, Row falsely asserts
that we're indexing beyond the column count by comparing against a stale
version of the column count.

The fix:
Rework the data migration to avoid nesting a deferred read transaction.
This is incorrect behavior. Now that our read is using our already open
write transaction with the same connection handle, it's understanding of
the schema is up-to-date during statement prep. So Row.init grabs the
current column count.
2021-09-30 13:00:26 -07:00
Michelle Linington
bfa4148cba Merge branch 'mlin/PR/EarlyRingForNSEWake' into release/5.21.2 2021-09-30 12:57:50 -07:00
Michelle Linington
b10613e37c Aggressively clear earlyRing flag 2021-09-30 12:57:41 -07:00
Michelle Linington
001245dcef Kick off a ring ASAP after launching the NSE 2021-09-30 12:57:41 -07:00
Matthew Chen
a0c753ab0a Merge branch 'charlesmchen/voipPushOnIOS15' into release/5.21.2 2021-09-30 16:51:33 -03:00
Matthew Chen
ebd9455428 Improve handling of voip pushes on iOS 15. 2021-09-30 16:41:32 -03:00
Matthew Chen
aba599241c Improve handling of voip pushes on iOS 15. 2021-09-30 16:41:32 -03:00
Matthew Chen
2a318c30fa Improve handling of voip pushes on iOS 15. 2021-09-30 16:41:32 -03:00
Matthew Chen
f68b7a5ff8 "Bump build to 5.21.2.1." (Internal) 2021-09-30 14:04:39 -03:00
Matthew Chen
b7709524be "Bump build to 5.21.2.0." (Internal) 2021-09-30 11:36:58 -03:00
Matthew Chen
efb95e510b "Feature flags for .qa." 2021-09-30 11:36:47 -03:00
Matthew Chen
cb4b6e06ea "Bump build to 5.21.1.5." (Beta) 2021-09-27 19:36:24 -03:00
Matthew Chen
51d0142ebf "Feature flags for .beta." 2021-09-27 19:36:21 -03:00
Matthew Chen
92af42b2d0 "Bump build to 5.21.1.4." 2021-09-27 19:36:17 -03:00
Matthew Chen
ae35b58ce3 "Feature flags for .production." 2021-09-27 19:36:09 -03:00
Matthew Chen
b756d24106 Update l10n strings. 2021-09-27 19:24:23 -03:00
Matthew Chen
914ddddc46 Update l10n strings. 2021-09-27 19:16:44 -03:00