Mailspring/packages/local-sync
Christine Spang 0644d2663d [local-sync] Fix UniqueConstraintError inserting contacts from messages
Summary:
Because of JavaScript's asynchronous nature, it is possible that we will
be processing several downloaded messages concurrently. This can lead to
calling extractContacts() in an interleaved fashion, which it was not
designed to handle. It looks up which contacts are already in the
database and then performs inserts or updates accordingly, assuming
nothing has changed in the contacts table in between---which is not
true! If several messages have similar contacts, an insert race can
cause one of the inserts to throw an unhandled exception.

We fix this by simply catching the unique constraint error, and falling
back to an update instead. (There's not really a better way to deal
with write races other than to enforce that we process contacts from
messages serially, as transactions are of no help here.)

This commit also removes extractContacts()'s return value, which is not
currently used and I found confusing.

Test Plan: manual

Reviewers: juan, evan, mark, jackie

Reviewed By: jackie

Differential Revision: https://phab.nylas.com/D3555
2016-12-23 18:31:51 -08:00
..
images [dashboard] Put dashboard into work window 2016-11-28 18:02:42 -08:00
spec fix(snippet-parsing): Don't add extraneous spaces after text format tags 2016-12-23 18:26:35 -08:00
src [local-sync] Fix UniqueConstraintError inserting contacts from messages 2016-12-23 18:31:51 -08:00
stylesheets [💄] fix eslint issues before they get overwhelming 2016-12-01 15:37:48 -08:00
main.es6 [dashboard] Put dashboard into work window 2016-11-28 18:02:42 -08:00
package.json [local-sync] fix missing dependency 2016-12-15 17:04:51 -05:00