Page MenuHomePhabricator

[native] handle database operations errors in reducer

Authored by kamil on Feb 13 2023, 6:08 AM.
Referenced Files
F2082022: D6713.id23155.diff
Sat, Jun 22, 11:55 PM
Unknown Object (File)
Thu, Jun 20, 7:07 AM
Unknown Object (File)
Mon, Jun 17, 3:31 PM
Unknown Object (File)
Fri, Jun 14, 1:35 AM
Unknown Object (File)
Wed, Jun 12, 4:31 AM
Unknown Object (File)
Wed, Jun 12, 12:30 AM
Unknown Object (File)
Sat, Jun 8, 10:35 PM
Unknown Object (File)
May 7 2024, 2:30 AM



Follow up to D5672.
If there will be an error while processing store operations we want to note this in secure store and kill app, after opening again database will be recreated.

This code introduces CommCoreModule method and calls it when needed.

Test Plan

Test functionality:

  1. Cause error in store operation - app should be killed
  2. Open again - new database should be created

Diff Detail

rCOMM Comm
Lint Not Applicable
Tests Not Applicable

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Feb 13 2023, 6:35 AM
1070 ↗(On Diff #22414)

Generally we have a convention that database operations (not only those that touch database directly) are executed on database thread, and relevant CommCoreModule methods return promises that are handled by JS. I consider it beneficial to stick to that convention. It was my mistake as a reviewer not to request another DatabaseManager methods to be called asynchronously on the C++ in your previous diffs. I would introduce this change in this differential and create follow up task on Linear to make other calls to DatabaseManager asynchronous on the C++ side as well.

1070 ↗(On Diff #22414)

We discussed this IRL, sharing context for reliability:

  • database thread is for running things connected to the database but this is not the case, flipping flag will do not have anything in common with SQLite or any other query executor, and might cause some actions (like clearSensitiveData) which touch database instance and will be scheduled on database thread
  • it's okay to use blocking calls in this case, not promise because we need information on whether database is okay or not before doing anything on it
  • we expect this function to be called right before killing app or at the very beginning of running the app, and things it changes will be addressed before doing anything with the database

so it's okay to leave this as it is

This revision is now accepted and ready to land.Feb 22 2023, 5:58 AM