Commit Graph

6931 Commits

Author SHA1 Message Date
Matthew Chen
cb782ca989 "Feature flags for .production." 2021-09-30 17:18:44 -03: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
Matthew Chen
2a318c30fa Improve handling of voip pushes on iOS 15. 2021-09-30 16:41:32 -03:00
Matthew Chen
efb95e510b "Feature flags for .qa." 2021-09-30 11:36:47 -03:00
Matthew Chen
51d0142ebf "Feature flags for .beta." 2021-09-27 19:36:21 -03:00
Matthew Chen
ae35b58ce3 "Feature flags for .production." 2021-09-27 19:36:09 -03:00
Matthew Chen
9696256d24 "Feature flags for .beta." 2021-09-27 19:07:29 -03:00
Matthew Chen
6ecf084b9f "Feature flags for .production." 2021-09-27 19:07:15 -03:00
Matthew Chen
e70302ac8f Refine NSE completion blocking, message processing. 2021-09-27 19:04:46 -03:00
Matthew Chen
0a8241adb4 "Feature flags for .qa." 2021-09-27 19:01:36 -03:00
Matthew Chen
a1490ecc99 "Feature flags for .production." 2021-09-24 23:39:44 -03:00
Matthew Chen
a448838cd7 Clean up logging. 2021-09-24 23:38:34 -03:00
Matthew Chen
3be6ae841b Refine NSE completion blocking. 2021-09-24 23:37:07 -03:00
Matthew Chen
1c1d6c1a5a Refine NSE completion blocking. 2021-09-24 23:37:07 -03:00
Matthew Chen
33f8c3c034 Fix contact diffing. 2021-09-24 22:52:28 -03:00
Michelle Linington
f4247dc91b Only drain head-of-batch envelopes when processing a batch 2021-09-24 18:36:35 -07:00
Michelle Linington
d32358007f Restore some log messages post-rebase 2021-09-24 18:36:35 -07:00
Michelle Linington
60d334ef1b Pause message processing in NSE when waking main app 2021-09-24 18:36:35 -07:00
Michelle Linington
6e188632b1 Skip acks of duplicate REST messages
Also more logging to correlate un-acked messages
2021-09-24 18:36:35 -07:00
Matthew Chen
6463531178 Respond to CR. 2021-09-24 18:30:42 -03:00
Matthew Chen
818634b23a Explicitly block NSE completion on posting notifications, sending acks, etc. 2021-09-24 18:30:42 -03:00
Matthew Chen
f511ca35df Refine NSE completion. 2021-09-24 18:30:42 -03:00
Matthew Chen
fc45ec8f63 Refine de-duplication logic. 2021-09-24 18:30:42 -03:00
Matthew Chen
564dcf87aa Elaborate logging around message processing. 2021-09-24 18:30:42 -03:00
Matthew Chen
11a97ef853 "Feature flags for .qa." 2021-09-24 00:04:43 -03:00
Matthew Chen
4f4cb32525 "Feature flags for .beta." 2021-09-24 00:04:37 -03:00
Matthew Chen
ee8f3dddb8 Merge branch 'release/5.20.4' 2021-09-23 23:51:34 -03:00
Matthew Chen
73b019f8da Refine decrypt deduplication. 2021-09-23 23:22:26 -03:00
Matthew Chen
ad1bdf48d6 Refine decrypt deduplication. 2021-09-23 23:16:41 -03:00
Matthew Chen
ddd7a9949a Refine decrypt deduplication. 2021-09-23 23:08:05 -03:00
Matthew Chen
59e33de962 Refine decrypt deduplication. 2021-09-23 22:49:44 -03:00
Matthew Chen
57f210c41d Merge branch 'release/5.20.4' 2021-09-23 18:12:06 -03:00
Matthew Chen
e88215c9b0 Elaborate logging around envelope decryption, decrypt de-duplication. 2021-09-23 18:10:02 -03:00
Matthew Chen
3b2c98e3df Disable websocket verbose logging. 2021-09-23 11:05:49 -03:00
Matthew Chen
2b1945f672 Clean up test logging. 2021-09-23 10:40:05 -03:00
Matthew Chen
b0fcd14a8c Tweak "deprecate REST" logic. 2021-09-23 10:28:42 -03:00
Matthew Chen
b058317777 Assert that GRDB schema/data migrations are complete before we warm caches. 2021-09-23 10:15:34 -03:00
Matthew Chen
c91ad2567d "Feature flags for .production." 2021-09-23 09:59:56 -03:00
Matthew Chen
2e41bdebda "Feature flags for .qa." 2021-09-23 09:59:11 -03:00
Matthew Chen
ad2e3f9222 "Feature flags for .beta." 2021-09-23 09:59:04 -03:00
Michelle Linington
e2e48fd749 Fix test compilation 2021-09-23 09:56:03 -03:00
Michelle Linington
172b8308ce Log envelope timestamp of duplicate envelopes 2021-09-23 09:56:03 -03:00
Michelle Linington
6cb440dc26 Fix tests 2021-09-23 09:56:02 -03:00
Michelle Linington
a9121b9ea3 Fix test compilation 2021-09-23 09:56:02 -03:00
Michelle Linington
52b127ddb0 Let WebSocket know about the nature of the processing failure 2021-09-23 09:56:02 -03:00
Matthew Chen
c4777a8023 Merge branch 'release/5.20.4' 2021-09-23 00:18:58 -03:00
Matthew Chen
01f7bb3ec1 Respond to CR. 2021-09-23 00:14:07 -03:00
Matthew Chen
1b46d06336 De-duplicate by serverGuid. 2021-09-23 00:08:02 -03:00
Matthew Chen
026b02c267 Deduplication message decryption to avoid spurious errors when NSE and main app message processing race. 2021-09-23 00:08:02 -03:00
Matthew Chen
e3845f7bc5 Update payments cert. 2021-09-22 23:32:47 -03:00