Closed Bug 335890 Opened 20 years ago Closed 20 years ago

nsIUpdateTimerManager doesn't work well for metrics

Categories

(Toolkit Graveyard :: Data Collection/Metrics, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bryner, Assigned: bryner)

Details

Attachments

(1 file, 1 obsolete file)

I originally just thought we had a units error when calling nsIUpdateTimerManager::registerTimer(), but it turns out there's more wrong here. The TimerManager defers timers by up to 10 minutes, which is really bad if your upload interval is 5 minutes. Also, I think the exponential backoff approach has the potential to send more requests than is good in the case where the configured server is actually down. So, I think we should get rid of nsIUpdateTimerManager and do the following: - Change the default upload interval (used if there's no config) to 5 minutes - Retry up to 3 times at the current interval in case of failure - If we fail 3 times, set a pref to indicate the next time we should attempt to upload. The target upload time will be randomly selected, anywhere from 12 - 36 hours in the future. - When setting up an nsITimer for upload, we'll first check the pref to see if there's a value there. If so, we'll set the timer for the delta to that time, or 0 if the time has passed. Otherwise, we'll use the interval from the client config. - Whenever we actually start an upload, clear out the upload-time pref.
Attached patch patch (obsolete) — — Splinter Review
This implements the above, plus: - Add a lot more NSPR logging to track success and failure of uploads - Null check |file| in OnStopRequest -- if the HTTP request is terminated during xpcom-shutdown, we'll be unable to create the DirectoryService to get the config file path.
Attachment #220220 - Flags: first-review?(marria)
Comment on attachment 220220 [details] [diff] [review] patch >+ PRInt32 interval_sec = kSecondsPerHour * 12; >+ PRUint32 random; >+ if (PR_GetRandomNoise(&random, sizeof(PRUint32)) != sizeof(PRUint32)) { >+ MS_LOG(("Failed to get random uint32, using uninitialized memory")); >+ } >+ >+ interval_sec += (random % (24 * kSecondsPerHour)); Could you add a comment explaining the new strategy for backing off the upload time? Also might want to consider looping until we have enough bytes, like the other callsite you mentioned. Otherwise looks good
Attachment #220220 - Flags: first-review?(marria) → first-review+
Blocks: 328064
Attached patch patch rev 2 — — Splinter Review
Fixes a few problems in the last patch: - Reset the retry count to 0 on successful upload - Retry at the server-specified upload interval, not at the default interval - Somewhat more robust usage of PR_GetRandomNoise - If we don't have a config, and there was a deferred upload time set, we should honor it instead of trying to upload right away - Flush the prefs file to disk after setting important prefs (which so far seems to be all of them). This ensures that we don't, for example, try to upload before the scheduled time because the app crashed before the metrics.upload.next-time pref was written out. - Enable NSPR logging of metrics in release builds to aid in debugging
Attachment #220220 - Attachment is obsolete: true
Attachment #220269 - Flags: first-review?(marria)
Comment on attachment 220269 [details] [diff] [review] patch rev 2 >+ // Any time an upload is successful, the failure count is reset to 0. >+ >+ if (NS_SUCCEEDED(status)) { >+ MS_LOG(("Successful upload")); > status = mConfig.Load(file); >+ if (NS_SUCCEEDED(status)) { >+ MS_LOG(("Read config file successfully, reset retry count to 0")); >+ mRetryCount = 0; >+ } >+ } What happens if we upload successfully but can't read the config file? It seems like we should set mRetryCount to 0 anyway Otherwise good
Attachment #220269 - Flags: first-review?(marria) → first-review+
(In reply to comment #4) > What happens if we upload successfully but can't read the config file? It > seems like we should set mRetryCount to 0 anyway Hm, I'd say if we couldn't read the config file it probably means the server didn't give us a valid one... which doesn't seem much different from any other kind of server error where we'd continue to retry. (Unfortuantely, MetricsConfig just silently returns OK if it got a file that doesn't have a valid DOM. We should fix this as well).
(In reply to comment #5) > (In reply to comment #4) > > What happens if we upload successfully but can't read the config file? It > > seems like we should set mRetryCount to 0 anyway > > Hm, I'd say if we couldn't read the config file it probably means the server > didn't give us a valid one... which doesn't seem much different from any other > kind of server error where we'd continue to retry. > > (Unfortuantely, MetricsConfig just silently returns OK if it got a file that > doesn't have a valid DOM. We should fix this as well). > Ok that's fine - I actually misread and didn't realize that it was falling through to the failure case below.
checked in
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
No longer blocks: 328064
Flags: first-review+
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: