Fix sync resource hog
Hypothesis: On receiving onChanged event of browser.storage.sync, sync will try to _merge_ the container data and backup the merged data. One of the merging process is called reconcileSiteAssignments in which sync will remove assigned site form the delete site list. On each removal sync will tell assignManager, the one who hold container data locally, to remove it as well. In turn the assignManager will remove *and then* tell sync to backup the data. This causes the backup process in sync to be invoked multiple times, one from the sync process and one for each of removed assigned site list. To make matters worse, the backup from removal of assigned site list will run in parallel from each others. This might fixes #1691.
This commit is contained in:
parent
8ef0a6f9f1
commit
f4a087d0ed
2 changed files with 4 additions and 4 deletions
|
@ -84,13 +84,13 @@ window.assignManager = {
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
async remove(pageUrlorUrlKey) {
|
async remove(pageUrlorUrlKey, shouldSync = true) {
|
||||||
const siteStoreKey = this.getSiteStoreKey(pageUrlorUrlKey);
|
const siteStoreKey = this.getSiteStoreKey(pageUrlorUrlKey);
|
||||||
// When we remove an assignment we should clear all the exemptions
|
// When we remove an assignment we should clear all the exemptions
|
||||||
this.removeExempted(pageUrlorUrlKey);
|
this.removeExempted(pageUrlorUrlKey);
|
||||||
await this.area.remove([siteStoreKey]);
|
await this.area.remove([siteStoreKey]);
|
||||||
const syncEnabled = await this.getSyncEnabled();
|
const syncEnabled = await this.getSyncEnabled();
|
||||||
if (syncEnabled) await sync.storageArea.backup({siteStoreKey});
|
if (shouldSync && syncEnabled) await sync.storageArea.backup({siteStoreKey});
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -493,9 +493,9 @@ async function reconcileSiteAssignments() {
|
||||||
await sync.storageArea.getDeletedSiteList();
|
await sync.storageArea.getDeletedSiteList();
|
||||||
for(const siteStoreKey of deletedSiteList) {
|
for(const siteStoreKey of deletedSiteList) {
|
||||||
if (Object.prototype.hasOwnProperty.call(assignedSitesLocal,siteStoreKey)) {
|
if (Object.prototype.hasOwnProperty.call(assignedSitesLocal,siteStoreKey)) {
|
||||||
assignManager
|
await assignManager
|
||||||
.storageArea
|
.storageArea
|
||||||
.remove(siteStoreKey);
|
.remove(siteStoreKey, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue