Commit graph

1095 commits

Author SHA1 Message Date
Juan Tejada a461490e41 [client-sync] Ensure we use refreshed access token for mail listener conn
Summary:
Before this commit, we would just establish a single mail listener imap
connection and never check if we needed to re-connect it due to an
expired access token. Even though we correctly refreshed the access
token at the beggining of each sync loop (hidden under
`ensureSMTPConnection`), we would never re-establish the mail listener
connection with the new access token.

This would cause the app to enter an `Invalid Credentials` error loop in
the sync loop, preventing from syncing any mail at all (T8064)

Test Plan: manual

Reviewers: spang, halla, mark, evan

Reviewed By: mark, evan

Differential Revision: https://phab.nylas.com/D4338
2017-04-04 13:27:43 -07:00
Juan Tejada 7dec807b28 [client-sync] Fix mail listener imap connection
Summary:
Given that we keep the imap mail listener conenction open outside of the
imap connection pool, it might close itself after a while or after
putting your computer to sleep.

Previously, if we had the connection object we just assumed it was
connected and proceeded with sync, and if it wasn't, we would fall into
an error loop in the sync worker preventing it from syncing at all (T8065)

To fix this, we just call `connect` every time to ensure the connection is open.
(This was the case before we introduced the connection pool)

Test Plan: manual

Reviewers: mark, spang, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4334
2017-04-04 13:27:04 -07:00
Mark Hahnenberg e06f729275 [client-app] Limit search to focused perspective
Summary:
Previously we would always search all mail. Now, if the user has focused
a particular folder we will limit our search to that folder. The inbox
is an exception--it will always search all mail unless the user
explicitly uses an "in:" clause.

Test Plan: Run locally, verify that searching folders returns the correct results.

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4328
2017-04-04 12:48:04 -07:00
Evan Morikawa f6bc2c4e5f bump(version): 2.0.0 2017-04-04 09:05:53 -07:00
Nylas Coffee Machine dfde1b9672 bump(version): 1.0.56 2017-04-04 09:03:34 -07:00
Halla Moore 7079b21b05 [client-sync] Don't assign duplicate roles in folder fetch
Summary:
Check that there aren't any other categories with a role before we try
to assign it to the current category.

Addresses T7835

Test Plan: manual

Reviewers: juan, evan, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4298
2017-04-03 17:04:25 -07:00
Evan Morikawa 2f082f8beb [client-app] re-setup IdentityStore in new window
Summary:
Before this patch, the IdentityStore would initialize in our empty hot
window. However, hot windows don't receive any `action-bridge-message`s,
which include DB updates. Since the hot window loads first, it was with a
stale verison of the Identity. The main window fetches a fresh identity,
but that fresh update failed to get to new composers because the hot
window wasn't listening to changes to the DB.

This makes it such that the IdentityStore properly boots up when the
window props change.

Test Plan: manual

Reviewers: halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4327
2017-04-03 16:44:01 -07:00
Evan Morikawa 368201f334 [client-app] add feature limits to reminders and send later
Summary:
This adds feature limit modals (graphics pending) for reminders and send
later

Test Plan: manual

Reviewers: juan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4322
2017-04-03 15:38:47 -07:00
Evan Morikawa 11684c6f9e [client-app] enable snooze, send later, reminders on 1.0.56
Summary: This enables packages on 1.0.56

Test Plan: manual

Reviewers: juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4320
2017-04-03 15:38:31 -07:00
Juan Tejada 020fd79db1 [client-app] Update changelog 2017-03-31 17:41:22 -07:00
Juan Tejada be237d076e [client-app] Remove unecessary db setup for mail rules
Summary: This shaves off ~150ms trying to issue this query

Test Plan: manual

Reviewers: evan, spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4317
2017-03-31 17:38:22 -07:00
Nylas Coffee Machine 7e0194e6c3 bump(version): 1.0.55 2017-03-31 16:14:55 -07:00
Evan Morikawa 96685bed01 [client-app] don't override existing bodies on K2
Summary:
Bodies that already exist on K2 shouldn't be overridden.
See the comment for how this caused open/link tracking to fail in certain
cases when a lot of messages were being sent

Test Plan: manual

Reviewers: halla, mark, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4319
2017-03-31 16:13:52 -07:00
Halla Moore 1864a2d48a [client-sync] Add comment about reason for try/catch block 2017-03-31 15:34:52 -07:00
Mark Hahnenberg 70bb602246 [client-sync] Split Contact ranking query
Summary:
We were using a join for the contact ranking query and for whatever
reason on large databases this was extremely slow in SQLite. This diff
splits the query into first finding the sent Folder/Label and then
searching for non-draft Messages in that category.

Test Plan: Run locally, verify the query is faster

Reviewers: juan, evan, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4315
2017-03-31 15:29:20 -07:00
Juan Tejada c4763d4bd5 [client-app] Update changelog 2017-03-31 15:01:10 -07:00
Mark Hahnenberg f6a0ead259 [client-app] Remove getUnindexedAccounts
Summary: It was really slow, and we no longer need it.

Test Plan: Run locally, verify that we no longer do that super slow query

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4312
2017-03-31 14:49:31 -07:00
Evan Morikawa e6b399ea27 [client-app] remove the ANALYZE in favor of pragma.optimize
Summary:
Removes some VERY long running `ANLAYZE` queries. Was taking up to 50
seconds on my 9GB database on every boot
https://sqlite.org/pragma.html#pragma_optimize

Test Plan:
I tested to make sure the app still quits quickly. It does. The SQLite
docs also say this should be fast.

Reviewers: halla, spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4314
2017-03-31 14:45:14 -07:00
Nylas Coffee Machine 328ea428be bump(version): 1.0.54 2017-03-31 12:22:21 -07:00
Mark Hahnenberg 0205ac3f61 [client-sync] Simplify Contact ranking query
Summary:
We were using a couple of left outer joins to avoid checking whether we
should be joining on Labels or Folders. We can greatly simplify the query
by just checking which we should use and issuing the correct inner join.

Test Plan: Run locally, verify contact ranking still works.

Reviewers: spang, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4310
2017-03-31 12:19:58 -07:00
Evan Morikawa 4deef8b90c [client-app] delay building new hot window to improve win perf
Summary:
This improves window open times by about 70ms
We would spend a very long time in the backend browser process building a
new hot window when we didn't need to do that until much later

Test Plan: manual

Reviewers: halla, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4311
2017-03-31 12:17:34 -07:00
Juan Tejada 590b17ae6f [client-app] Don't imeout removing sync worker when removing an account
Summary:
Most of the times when removing a sync worker (i.e. when removing an
account), we would see database errors in the console. This happened
because more often than not we would interrupt in the middle of message
processing, but `processMessage` is not interruptible, which means that
the worker would be interrupted right after processing its current
message. However, if `processMessage` would take more than 500ms (the
current timeout for stopping the worker), we would destroy the database
before processing was done and it would throw a bunch of errors.

To fix this, we just don't set a timeout when removing the worker as a consequence
of removing an account. However, when we are removing the worker when we
detect that it is stuck, we set a time out of 5 seconds.

Test Plan: manually test removing accounts, verify that it doesn't error

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4308
2017-03-31 12:09:20 -07:00
Juan Tejada 9181914453 [client-app] Ensure sync worker can never continue running after being destroyed
Summary:
Previously, it was possible for the sync worker to continue running after being
interrupted, e.g. it would break out of `performSync` and then try to run
`onSyncCompleted`. This is fine if we were just interrupting to restart the loop,
but when we stop it we don't want it to continue running anything at all.

This also refactors the syncworker to have a single `destroy` method, which sets
a `destroyed` flag and uses that one exclusively instead of the `stopped` flag.

Test Plan: manually check it works

Reviewers: spang, halla, mark, evan

Reviewed By: mark, evan

Differential Revision: https://phab.nylas.com/D4307
2017-03-31 12:08:48 -07:00
Juan Tejada 58cf02a824 [client-app] Don't hit contact rankings endpoint until account is ready
Summary:
This prevents us from hitting the endpoint before the database for that
account is initialized and it's actually syncing.

Before this commit, we would throw errors upon adding an account

Test Plan: manually add, remove accounts, run benchmark script

Reviewers: mark, halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4305
2017-03-31 11:21:56 -07:00
Halla Moore af6e6e669a [client-sync] Wrap more syncWorker args
Turns out the SyncWorker isn't the only one who initiates SyncTasks
2017-03-31 11:12:50 -07:00
Halla Moore ae2e2122e9 [client-sync] Properly wrap the SyncWorker arg in an object
The argument structure for runTask() changed and needs it this way.
2017-03-31 10:58:16 -07:00
Halla Moore c6a339df1a [client-sync] Fix the new syncback-task structure
Summary:
- Change files to .es6 so they recognize the syntax
- Pass arguments down to _run()
- Make sure the responses get returned

Test Plan: manual, even though that somehow failed before. :(

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4309
2017-03-31 10:52:42 -07:00
Nylas Coffee Machine 13ac2fa3b4 bump(version): 1.0.53 2017-03-31 09:07:20 -07:00
Evan Morikawa ae278fa5f2 [client-app] add DatabaseStore.write which doesn't use Transactions
Summary:
Creates a new `DatabaseStore.write` method alongside
`DatabaseStore.inTransaction` that doesn't always wrap trivial queries in
a transaction. SQLite does this automatically.

Test Plan: manual

Reviewers: spang, mark, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4303
2017-03-30 17:38:32 -07:00
Evan Morikawa 559ecb1cda [client-app] rename DatabaseTransaction -> DatabaseWriter
Summary: Renamed in prep for next few diffs

Test Plan: manual

Reviewers: juan, mark, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4302
2017-03-30 17:38:07 -07:00
Evan Morikawa f9c0a93d1c [client-app] use debug library for DB
Summary:
Use the wonderful `debug` library instead of all our random flags.
You can now do things like: `DEBUG="app:*,sync:*" npm start` to print out
everything.

Test Plan: manual

Reviewers: mark, halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4297
2017-03-30 17:26:33 -07:00
Halla Moore f5f5b60140 [client-sync] Add provider to syncbackTask perf metric 2017-03-30 16:24:32 -07:00
Halla Moore a776e6dfb7 [client-sync] Report metrics about SyncbackTask runs
Summary:
Report how long they take and if they're stopped (due to timeout).

Part of T7978

Test Plan: manual

Reviewers: evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4272
2017-03-30 16:15:09 -07:00
Mark Hahnenberg 5c08018382 [client-app] Add search support for "has:attachment"
Summary: See title

Test Plan: Run locally, verify that attachments are returned

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4293
2017-03-30 16:11:19 -07:00
Halla Moore 4c1af8f184 [client-sync] Convert syncback tasks to interruptible generators
Summary:
Make `run()` functions generators and change most awaits to yields

Part of T7978

Test Plan: specs from D4269, but really needs some heavy QA

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4270
2017-03-30 15:51:25 -07:00
Halla Moore c11a7ff830 [client-sync] Interrupt long-running syncback tasks
Summary:
Interrupt retryable syncback tasks that are taking too long so that we can
return control to the sync loop. The sync loop will retry the task later.
This diff adds a `forceReject` param to `interrupt()` so that we can return
control immediately instead of waiting for the current operation to finish
(for instance, the syncback task could be stuck in an imap operation, and a
normal interrupt would still have to wait for that to finish before returning
control to the callee)

Part of T7978

Test Plan: specs

Reviewers: evan, spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4269
2017-03-30 15:50:34 -07:00
Juan Tejada 2d1a3714d8 [client-app] Update changelog 2017-03-30 10:18:48 -07:00
Evan Morikawa b72e0829f2 [client-app] Add silent flag to DB persists for thread indexing
Summary:
Every persistModel would trigger a large number of downstream updates.
These weren't necessary for thread indexing and causing a lot of
unnecessary DB thrashing. This adds a `silent` flag to `persistModel` and
its ilk that just does the write.

significantly improve performance, and also contribute to T8046

Test Plan: manual

Reviewers: spang, mark, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4295
2017-03-30 09:36:07 -07:00
Evan Morikawa 2b67f139ea [client-app] Add better DB logging with ENABLE_SEQUELIZE_DEBUG_LOGGING
Summary:
This adds better logging to the DB

You can use `ENABLE_SEQUELIZE_DEBUG_LOGGING=true` and
`ENABLE_RXDB_DEBUG_LOGGING=true` to spit out the raw queries of both DBs.

Test Plan: manual

Reviewers: mark, halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4294
2017-03-30 09:32:52 -07:00
Nylas Coffee Machine 5196f0eee7 bump(version): 1.0.52 2017-03-29 23:50:58 -07:00
Mark Hahnenberg df1acb84b1 [client-app] Fix thread reindexing loop
Summary:
We would mark modified threads for reindexing, the thread search indexer
would reindex them, which would trigger a notification that the thread
had been modified, so we would mark the thread for reindexing, ...

Now we keep track in memory of which threads we've marked for reindexing
so we avoid re-marking them when the update notification arrives later.

Test Plan:
Run locally, verify same threads aren't getting continuously
reindexed and that the in-memory set doesn't grow unboundedly

Reviewers: spang, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4289
2017-03-29 17:00:40 -07:00
Juan Tejada c7e4c2bb87 [client-app] Fix references to RetryableError imports
Summary: See title

Test Plan: manual

Reviewers: spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4292
2017-03-29 15:51:09 -07:00
Juan Tejada caac7cd247 [client-app] Log duration of db ANALYZE query
Summary: See title

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4290
2017-03-29 15:01:31 -07:00
Juan Tejada ec51e982eb [client-app] Improve logging for queries
Summary:
This commit makes a few changes to how we log database queries:

- We log queries in 2 different places now:
  - When `DatabaseStore._executeLocally` takes longer than 100ms. This might be due to the actual db operation taking long, or it might be due to our retry logic, or potentially other factors.
  - When the actual raw database operation takes more than 100ms.
- When raw database queries take more than 100ms, we log out the query plan if it is a `SELECT` query and we are in dev mode.
- If `DEBUG_TO_LOG` is true, we always log all queries (including background queries)

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4288
2017-03-29 15:01:07 -07:00
Juan Tejada d26a3e7448 [client-app] Improve logging for background database queries
Summary:
- Rename `databaseAgent` usage to `background`, in the code and in the logs, which I
believe is less confusing. Often times found myself asking what was this agent thing in
the logs.
- Make messaging more explicit

Test Plan: manual

Reviewers: evan, mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4285
2017-03-29 15:00:44 -07:00
Juan Tejada 8e03ca65ef [client-app] Reduce max retry delay for db queries
Summary:
This commit makes it so that when we retry database queries after
encountering a db locked error, we back off for at most 500ms, instead
of the current max of 3s. This meant that a single query could
potentially take 3+ seconds and block the transaction queue for that long.

Test Plan: manual

Reviewers: evan, mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4283
2017-03-29 15:00:12 -07:00
Juan Tejada 745dac7582 [client-app] Don't delay db queries unless we are retrying
Summary:
After introducing retry logic, we would always defer db queries to the
next tick even if there was no retry delay present.

This would cause almost all db queries take more than 100ms even if the
actual db operation was really fast. This affected app performance
negatively

Test Plan: manual

Reviewers: evan, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4282
2017-03-29 14:59:34 -07:00
Evan Morikawa 9d15ff7ff7 [client-app] ensure gmail msg to 1 person get tracking stripped
Summary:
The problem actually was that we weren't applying the transform for Gmail
messages sent to 1 recipient

Test Plan: manual

Reviewers: halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4291
2017-03-29 14:53:57 -07:00
Evan Morikawa d8e22aa936 [client-app] don't trigger your own opens & link clicks
Summary:
We weren't stripping link and open items from messages we sent properly.
While we stripped it from the first outgoing message, when the sync loop
came back around it would have them back in. This adds it in the message
processor to extra ensure that ANYTHING that comes from us (or one of our
aliases) gets the open/link tracking stripped

Test Plan: New tests

Reviewers: juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4287
2017-03-29 14:53:40 -07:00
Mark Hahnenberg 78b9cf81c5 [client-sync] Fix "in:" for IMAP search
Summary:
Prior to this diff, the "in:" search query syntax didn't work for IMAP.
This diff implements "in:" by changing the IMAP search backend to take
folder context into account and emit the appropriate queries for each
folder. Queries that include "in:foo" will replace the corresponding AST
nodes with 'ALL' or 'NOT ALL' depending on whether or not the current folder
is "foo". We also now filter which folders we search based on which
folders are referenced in the query.

Test Plan: Run locally, verify that in: works quickly

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4284
2017-03-29 13:48:46 -07:00