Commit Graph
286 Commits
Author SHA1 Message Date
Edouard Oger 56694b527f Bug 1361534 - Fix typo in AndroidFxAccount. r=eoger
MozReview-Commit-ID: EhMWO9jmLJ8
2017-05-02 18:52:21 -04:00
Andrzej Hunt 6a9fd1151f Bug 1356693 - infer: fix RESOURCE_LEAK's in services r=Grisha
The primary issue is that we use a throwing InputStreamReader
constructor. If it throws, then any nested streams will be lost.
We can fix that by using the non-throwing InputStreamReader
constructor (which uses a Charset as the second parameter,
instead of a String which causes an Exception to be thrown
if it can't be parsed)

We also simplify some nested Stream's a little: most of the
Stream constructors don't throw, so there's no harm in not keeping
individual references to those that don't throw - and that
results in less Stream references for us to handle.

MozReview-Commit-ID: 2hyRFGVmGnU
2017-04-14 20:58:59 -07:00
Carsten "Tomcat" Book 0dbb80534e Backed out changeset 6d26ad68f31f (bug 1356693) 2017-04-27 15:19:50 +02:00
Andrzej Hunt 19a99a0a56 Bug 1356693 - infer: fix RESOURCE_LEAK's in services r=Grisha
The primary issue is that we use a throwing InputStreamReader
constructor. If it throws, then any nested streams will be lost.
We can fix that by using the non-throwing InputStreamReader
constructor (which uses a Charset as the second parameter,
instead of a String which causes an Exception to be thrown
if it can't be parsed)

We also simplify some nested Stream's a little: most of the
Stream constructors don't throw, so there's no harm in not keeping
individual references to those that don't throw - and that
results in less Stream references for us to handle.

MozReview-Commit-ID: 2hyRFGVmGnU
2017-04-14 20:58:59 -07:00
Edouard Oger 842aa56844 Bug 1351805 part 3 - Refresh the remote devices list on Married/Engaged states. r=Grisha
MozReview-Commit-ID: 1Ktbtlzc1fI
2017-04-19 17:45:49 -04:00
Edouard Oger 87f243259e Bug 1351805 part 1 - Create a org.mozilla.gecko.fxa.devices package. r=Grisha,nalexander
MozReview-Commit-ID: FjJmRiHlqEg
2017-04-07 11:56:38 -04:00
Wes Kocher e5cf37107d Backed out 3 changesets (bug 1351805) for android Test failures a=backout
Backed out changeset da34da5f310a (bug 1351805)
Backed out changeset 430b56176e04 (bug 1351805)
Backed out changeset a3dfb4b9dc66 (bug 1351805)

MozReview-Commit-ID: AE4RcKV3akz
2017-04-25 12:47:59 -07:00
Edouard Oger 24a859fd50 Bug 1351805 part 3 - Refresh the remote devices list on Married/Engaged states. r=Grisha
MozReview-Commit-ID: 1Ktbtlzc1fI
2017-04-19 17:45:49 -04:00
Edouard Oger bfc7019308 Bug 1351805 part 1 - Create a org.mozilla.gecko.fxa.devices package. r=Grisha,nalexander
MozReview-Commit-ID: FjJmRiHlqEg
2017-04-07 11:56:38 -04:00
Edouard Oger b838bef9e9 Bug 1349299 - Register device on FxA even on Push registration failure. r=Grisha
MozReview-Commit-ID: 3qDkm9iV9C0
2017-04-06 11:30:23 -04:00
Grigory Kruglov db41155369 Bug 1335198 - Add support for synchronizing bookmark creation date r=rnewman
Incoming records might be missing the dateAdded field, and so we perform some pre-processing:
- during reconciliation, dateAdded is set to the lowest of (remote lastModified, remote dateAdded, local dateAdded)
- during insertion, if dateAdded is missing it is set to lastModified

Whenever we modify dateAdded for a record during sync, we also bump its lastModified value. This will trigger an
upload of this record, and consequently a re-upload by clients which are able to provide an older dateAdded value.
It is possible that this might cause conflicts on other devices, but the expected likelyhood of that happening is low.


MozReview-Commit-ID: 3tDeXKSBgrO
2017-04-18 18:04:45 -04:00
Grigory Kruglov 22864fe6de Bug 1350442 - Remove redundant storeDone from the RepositorySession class r=rnewman
Confusion between storeDone() and storeDone(long end) resulted in certain sessions (bookmarks
and form history) not overriding the current method. As a result, their final "flush the queue"
methods weren't being called by the buffering middleware.

This patch removes the storeDone(long end) method, making such confusion a non-issue.

Given that a lot of sessions tend to build up buffers which they need to then flush after a storeDone()
call, passing in a timestamp into that method doesn't make sense. Instead, let's supply a default
implementation in RepositorySession which calls onStoreCompleted(endTimestamp) with current time,
and allow sessions to override this method and own the onStoreCompleted(endTimestamp) call.

MozReview-Commit-ID: 84o7aAL8RPC
2017-03-31 19:00:13 -04:00
Grigory Kruglov 3a23ec83b6 Bug 1350442 - Use the main storeWorkQueue for failures in the buffering middleware r=rnewman
MozReview-Commit-ID: ByZtR5zSKZB
2017-04-04 17:15:02 -04:00
Grigory Kruglov 6eac7d31ad Bug 1343726 - Ensure that bookmark folders are processed first by the uploader r=rnewman
Since we're uploading records atomically, order in which they're processed by the uploader
only matters if we want to do sanity checks on certain types of records. Server might still
preserve some of the order, but for our purposes here it shouldn't matter.

We'd like to ensure that we process the "mobile root" bookmark record along with other folder
records first, so that we increase our chances of avoiding making a failing network request if
that those records' payload is too large.

Sorting by bookmark type achieves this.

MozReview-Commit-ID: KrAs3zepaOk
2017-03-15 14:12:13 -07:00
Grigory Kruglov 862b7aa8f6 Bug 1343726 - Respect max_record_payload_bytes limit while uploading records r=rnewman
If we try to upload a record whose payload BSO field is larger than the limit specified
by the server, fail that record during BatchingUploader's processing.

Consequently, Synchronizer will fail current sync stage and advance to the next.

Previous behaviour was to essentially rely on the server to fail our POST request,
at which point we'll fail current sync stage. So in a way, this is an optimization to
avoid making network requests which we know will fail.

MozReview-Commit-ID: 5aJRRNoUuXe
2017-03-15 13:51:31 -07:00
Grigory Kruglov 53d9f658c0 Bug 1352608 - Close a cursor after we're done with it r=eoger
Removed "final" because "safeQuery" provides terrible developer ergonomics.

MozReview-Commit-ID: 2F0XZnBM3Yv
2017-03-31 20:22:06 -04:00
Ryan VanderMeulen 3866e9cf31 Merge inbound to m-c. a=merge 2017-03-29 09:41:54 -04:00
Grigory Kruglov c8d3c28e3a Bug 1350196 - Part 2: Perform PRNGFixes earlier. r=rnewman, r=nalexander
MozReview-Commit-ID: 18jnRRFhyPq
2017-03-27 18:32:54 -07:00
Grigory Kruglov 444e92cd70 Bug 1350196 - Part 1: Generate IV ourselves. r=rnewman, r=nalexander
MozReview-Commit-ID: 5rR8BQRcJoR
2017-03-27 18:40:02 -07:00
Edouard Oger 9d163bfda3 Bug 1346061 part 3 - Trigger a sync/email-verification-check on empty FxA push message. r=Grisha,nalexander
MozReview-Commit-ID: ABUm6LZij4M
2017-03-22 13:10:09 -04:00
Edouard Oger e9a39fbf1c Bug 1346061 part 2 - Register device on FxA on Engaged state. r=Grisha,nalexander
MozReview-Commit-ID: 3HrXePgBxg6
2017-03-22 13:11:34 -04:00
Edouard Oger 448e1fed7b Bug 1346061 part 1 - Expose getSessionToken() on State. r=Grisha,nalexander
We need to access sessionToken in the Engaged state in order to perform device
registration. We expose getSessionToken() on the base State class, to allow
customers to get the sessionToken easily instead of having to downcast the
TokensAndKeysState/Engaged states.

MozReview-Commit-ID: 8s2C350noUG
2017-03-22 13:07:00 -04:00
Edouard Oger a6834582f3 Bug 1265314 - Set tabs record lastModified to clients.lastModified. r=nalexander
MozReview-Commit-ID: 84g7WXxRwdX
2017-03-24 15:40:34 -04:00
Grigory Kruglov 80227b5d3d Bug 1346438 - Specify X-I-U-S header value as 0 when uploading crypto/keys r=nalexander
MozReview-Commit-ID: GTcZUdvVU8E
2017-03-17 19:09:43 -07:00
Grigory Kruglov 0883c803e4 Bug 1346438 - Specify X-I-U-S header value while uploading meta/global r=nalexander
We upload meta/global in three scenarios:
- fresh start
- when it was modified after a successful sync
- when it was modified after an aborted sync

Use X-I-U-S header to assert what we believe about meta/global's presence (during freshStart)
and last-modified timestamp (in all other cases).

We might encounter a concurrent modification condition, manifesting as a 412 error. If we see such an error:
- on fresh start, we restart globalSession
- on regular upload, we request a re-sync of all stages

MozReview-Commit-ID: 3qyb6rUSOeY
2017-03-20 16:40:13 -07:00
Edouard Oger fb4be5746b Bug 1254643 - Delete FxA device when Fennec Firefox Account is removed. r=Grisha
MozReview-Commit-ID: H4lJlXGYIBg
2017-03-13 14:35:41 -04:00
Grigory Kruglov 897f1a8cd9 Bug 1346390 - Use Long.parseLong instead of Long.valueOf for efficiency r=nalexander
MozReview-Commit-ID: 29fwjlxRqZ3
2017-03-10 13:17:51 -08:00
Grigory Kruglov c84ce69e9a Bug 1329793 - Re-subscribe for a push channel periodically r=eoger,nalexander
On startup and at the beginning of a sync we check how long it has been since we've subscribed
to a channel for fxa service. If it's been over 21 days, request re-subscription.

MozReview-Commit-ID: GzvPecZ9hTy
2017-03-08 18:14:43 -08:00
Grisha Kruglov dc28277d01 Bug 1291821 - Post: remove unused files r=rnewman
MozReview-Commit-ID: 4qM5vx4AQyQ
2016-11-29 13:36:26 -08:00
Grisha Kruglov 37a9189269 Bug 1291821 - Allow BatchingDownloader to resume downloads using offset r=rnewman
BatchingDownloader uses provided RepositoryStateProvider instance in order to track
offset and high water mark as it performs batching.

The state holder objects are initialized by individual ServerSyncStages, and prefixes are used to ensure keys
won't clash.

Two RepositoryStateProvider implementations are used: persistent and non-persistent. Non-persistent
state provider does not allow for resuming after a sync restart, while persistent one does.

Persistent state provider is used by the history stage. It is fetched oldest-first, and records are applied
to live storage as they're downloaded. These conditions let use resume downloads. It's also possible to
resume downloads for stages which use a persistent buffer, but currently we do not have any.

Offset value and its context is reset if we hit a 412 error; it is maintained if we hit a sync deadline, allowing us to
minimize number of records we'll redownload. BatchingDownloaderController owns resuming and context checking logic.

High water mark (h.w.m.) is maintained across syncs and used instead of stage's "last-synced" timestamp if said stage is
set to fetch oldest-first and explicitely allows use of a h.w.m. Server15RepositorySession provides correct timestamp
to RecordsChannel, decoupling BatchingDownloader from this logic.

MozReview-Commit-ID: IH28YrDU4vW
2017-01-19 13:11:18 -08:00
Grisha Kruglov dd5f110508 Bug 1291821 - Track incomplete stages and re-sync them r=rnewman
Stage re-sync is requested if:
- We hit a 412 either during batching download or batching upload
- We hit a sync deadline either during batching download or when merging records from the buffer

SessionStoreDelegate interface was expanded with onStoreFailed,
indicating that not just a particular record failed, but the whole operation did.

onFetchFailed is used to inform delegates of 412/deadline failures during downloads.
Three new exception types were added, to facilitated messaging between different layers.

MozReview-Commit-ID: Ltdi5noEvdV
2017-02-24 13:04:54 -08:00
Grisha Kruglov 6694eb16a3 Bug 1291821 - Move bulk insert logic for new history to BrowserProvider r=rnewman
This commit does two things:

1) It simplifies history insertion logic, which wrongly assumed that history which was
being inserted might be not new. As such, it was necessary to check for collisions of
visit inserts, record number of visits actually inserted, and update remote visit counts
correspondingly in a separate step, making history insert a three step operation (insert
history record, insert its visits, update history record with a count). However, bulkInsert
runs only for records which were determined to be entirely new, so it's possible to drop
the third step.

2) Makes all of the insertions (history records and their visits) run in one transaction.
Prepared statements for both history and visit inserts are used are used as a
performance optimization measure.

MozReview-Commit-ID: 48T4G5IsQNS
2016-11-29 13:42:53 -08:00
Grisha Kruglov 450845fdce Bug 1291821 - Rename repositories/sessions r=rnewman
We're at Sync 1.5 now, so might as well rename the files.

Also, renamed the ConstrainedRepository... to a name that's more reflective
of that session's role after the changes.

MozReview-Commit-ID: 96XCzoBzD5D
2017-02-24 13:04:15 -08:00
Grisha Kruglov 16901278c4 Bug 1291821 - Ensure sink repository is aware of new events coming from the source r=rnewman
MozReview-Commit-ID: DgqGzfoJxhj
2016-10-11 20:00:09 -07:00
Grisha Kruglov 7ef52aeb7d Bug 1291821 - Split history stage into recent and full history stages r=rnewman
Recent history stage will only run if full history stage did not complete yet.
Bug 1316110 tracks follow up work to make this more efficient.

MozReview-Commit-ID: 7dtbfEFUMGB
2016-11-16 14:53:07 -08:00
Grisha Kruglov 711526ea3c Bug 1291821 - Wrap local repositories in buffering middleware r=rnewman
History stage does not wrap history respository in a buffer, because we'd like to
use a high-water-mark and offset resuming later on, and using a persistent buffer
for this stage does not make sense.

MozReview-Commit-ID: FS1swml2bIC
2016-10-20 16:31:31 -07:00
Grisha Kruglov bb597858e6 Bug 1291821 - Use sync deadline to decide of batching downloader should proceed r=rnewman
MozReview-Commit-ID: IDgIj9lBt61
2016-11-01 18:52:18 -07:00
Grisha Kruglov 41b38d6a1a Bug 1291821 - Keep track of sync deadline r=rnewman
MozReview-Commit-ID: Fvuc05K1arV
2016-11-08 12:38:00 -08:00
Grisha Kruglov 6c724c5e88 Bug 1291821 - Remove total sync limits, refactor batching downloader r=rnewman
MozReview-Commit-ID: 2SYxemfTv9V
2016-10-20 13:34:06 -07:00
Grisha Kruglov 5cefe7fd87 Bug 1291821 - Decouple BatchingUploader from Server11Repository r=rnewman
MozReview-Commit-ID: 7mPy1cmr3vq
2016-11-01 18:55:15 -07:00
Grisha Kruglov 157f1c2da3 Bug 1291821 - Simplify onFetchFailed, clean up some exception code r=rnewman
MozReview-Commit-ID: 11sIAPCfLWk
2016-10-11 19:29:46 -07:00
Grisha Kruglov 7b9c7bffd2 Bug 1291821 - Add onBatchComplete to a FetchRecordsDelegate r=rnewman
Intended to signal that a group of records have been fetched, and more are
to come after a pause.

MozReview-Commit-ID: 8ozZTc6aNdA
2016-10-11 19:29:02 -07:00
Grisha Kruglov e4b277828a Bug 1291821 - Rename RepositorySession's delegate to storeDelegate, for clarity r=rnewman
Otherwise we often end up with delegate meaning both fetch delegate and store delegate
in extending classes, which gets a little confusing.

MozReview-Commit-ID: L4Sd79jLr88
2016-10-08 17:03:38 -07:00
Grisha Kruglov 1de5849645 Bug 1291821 - Switch stage duration interval counting to use elapsedRealtime r=rnewman
It is a better fit for interval counting.

MozReview-Commit-ID: LCF0U24MAwF
2016-10-08 15:28:14 -07:00
Grisha Kruglov 96b897ab0f Bug 1291821 - Buffering repository middleware r=rnewman
MozReview-Commit-ID: GS3M7k670Po
2017-01-19 13:11:41 -08:00
Grisha Kruglov 8a8e4be790 Bug 1291821 - Add storeIncomplete to RepositorySession interface r=rnewman
MozReview-Commit-ID: 68ty7KlP5NR
2016-11-02 16:40:15 -07:00
Grisha Kruglov eb602f919b Bug 1291821 - Pre: remove unused SerialRecordConsumer r=rnewman
MozReview-Commit-ID: 3fiHVErUA1g
2016-10-08 14:49:46 -07:00
Grigory Kruglov dd41766931 Bug 1336001 - Refactor BatchingUploader's state-holder objects to fix threading problems r=rnewman
Previous state:
- Two threads were racing to get to batchMeta - one to reset its state, and the other to
read its internal state to construct a network request, and then to update its internal state.
- This resulted in data corruption when payloads had to be split into multiple batches.

A core problem was that there is a lot of state shared across thread boundaries. Specifically,
BatchMeta is being written and read both by record consumer threads running off of a thread pool,
and by the network worker thread(s).

This patch refactors BatchMeta and scheduling of network runnables to ensure that cross-thread access
is minimized, and "who owns/accesses what" is explicit.

- PayloadDispatcher owns scheduling payload runnables and any data they need to share between each other.
- UploaderMeta owns information that's necessary to process incoming records.


MozReview-Commit-ID: 9hFs3fXGaGM
2017-02-22 11:26:35 -08:00
Carsten "Tomcat" Book 8e01544ca5 Merge mozilla-central to autoland 2017-02-22 14:47:47 +01:00
Grigory Kruglov 95c1a5936b Bug 1341125 - Clear accounts in-memory cache when necessary. r=nalexander
MozReview-Commit-ID: sf5WhXxRVg
2017-02-21 11:31:22 -08:00