Closed Bug 349253 Opened 18 years ago Closed 18 years ago

implement backoff code for table updates

Categories

(Toolkit :: Safe Browsing, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 2

People

(Reporter: tony, Assigned: tony)

References

Details

(Keywords: fixed1.8.1)

Attachments

(1 file, 2 obsolete files)

In the same vein as bug 349102, we want to degrade gracefully if url table updates are failing. The logic is similar to what happens in the search service, if we get too many errors in a certain time period, we stop making requests for a while. If we continue to get errors, we double our timeout.
There are some manual unittests at the end of the request-backoff.js.
Attachment #234518 - Flags: review?(provos)
Comment on attachment 234518 [details] [diff] [review] v1: requestbackoff class and logic for table updates it looks like it takes max_errors + 1 errors to trigger the backoff. i dont understand why you have a while loop. you just want to shift so that you have at more MAX_ERRORS in the array. you just need to check if the last MAX_ERRORS errors fall in the time period. i am not sure if you want to clear the errors if you get an okay response. rest looks good to me.
- use 'if' rather than 'while' - make it more explicit what happens on successful request - make sure to reset the object if data provider is changed It triggers on max errors since it pushes the current time in the list first. See unittests which confirm this.
Attachment #234518 - Attachment is obsolete: true
Attachment #234613 - Flags: review?(provos)
Attachment #234518 - Flags: review?(provos)
Comment on attachment 234613 [details] [diff] [review] v2: requestbackoff class and logic for table updates looks good.
Attachment #234613 - Flags: review?(provos) → review+
Attachment #234613 - Flags: superreview?(darin)
Comment on attachment 234613 [details] [diff] [review] v2: requestbackoff class and logic for table updates >Index: toolkit/components/url-classifier/content/request-backoff.js >+// HTTP responses that count as an error. >+const HTTP_FOUND = 302; // DOS detected message >+const HTTP_INTERNAL_SERVER_ERROR = 500; >+const HTTP_BAD_GATEWAY = 502; >+const HTTP_SERVICE_UNAVAILABLE = 503; Why not restrict success codes instead? A proxy server between Firefox and the server might introduce other error codes besides these ones, so perhaps it would be better to make this code less particular? >+/** >+ * Notify this object of the last server response. If it's an error, >+ */ >+RequestBackoff.prototype.noteServerResponse = function(status) { >+ if (HTTP_INTERNAL_SERVER_ERROR == status || >+ HTTP_BAD_GATEWAY == status || >+ HTTP_SERVICE_UNAVAILABLE == status || >+ HTTP_FOUND == status) { It seems like this should just test for non-200 responses or maybe it should check for !200 and !206. >Index: toolkit/components/url-classifier/src/nsUrlClassifierStreamUpdater.cpp >+ rv = httpChannel->GetRequestSucceeded(&succeeded); >+ NS_ENSURE_SUCCESS(rv, rv); >+ > if (!succeeded) { >+ // 404 or other error, pass error status back >+ LOG(("HTTP request returned failure code.")); >+ >+ PRUint32 status; >+ rv = httpChannel->GetResponseStatus(&status); >+ NS_ENSURE_SUCCESS(rv, rv); Note: connection failures that prevent a HTTP response from being generated would not have a HTTP response code. Instead GetResponseStatus would return the error NS_ERROR_CONNECTION_REFUSED (or something like that). Perhaps you should treat those kinds of errors as reasons for backing off as well? >+ nsCAutoString strStatus; >+ strStatus.AppendInt(status); >+ mErrorCallback->HandleEvent(strStatus); > return NS_ERROR_ABORT; Shouldn't you generate an Error callback whenever you fail to generate the Table callback? In other words, maybe an Error callback should be generated whenever you would need to return an error from this function. Also, what about the CancelStream case... should that result in an Error callback being generated?
Flags: blocking-firefox2?
(In reply to comment #5) > > Why not restrict success codes instead? A proxy server between Firefox > and the server might introduce other error codes besides these ones, so > perhaps it would be better to make this code less particular? > > It seems like this should just test for non-200 responses or > maybe it should check for !200 and !206. It seems like there should be three possibilities: ok, error with backoff, error without backoff. Right now anything other than 200 would be error without backoff which seems ok. The proxy case seems like something a bit fragile. Would matching status in the range 500-505 be better? > Note: connection failures that prevent a HTTP response from being generated > would not have a HTTP response code. Instead GetResponseStatus would return > the error NS_ERROR_CONNECTION_REFUSED (or something like that). Perhaps you > should treat those kinds of errors as reasons for backing off as well? Would this happen if the user wasn't online? In which case, I don't think we want to trigger backoff. Also, does onDataAvailable get fired in this case? > Shouldn't you generate an Error callback whenever you fail to generate the > Table callback? In other words, maybe an Error callback should be generated > whenever you would need to return an error from this function. Also, what > about the CancelStream case... should that result in an Error callback being > generated? I've renamed the method to be httpErrorCallback because that's what all we care about (I'll post the updated patch once I hear back about the other issues).
Flags: blocking-firefox2? → blocking-firefox2+
Target Milestone: --- → Firefox 2
From discussion offline: - error codes now include 302, 303, 307 and 5xx - connection_refused also counts as an error
Attachment #234613 - Attachment is obsolete: true
Attachment #234965 - Flags: superreview?(darin)
Attachment #234613 - Flags: superreview?(darin)
Attachment #234965 - Flags: superreview?(darin) → superreview+
on trunk
Attachment #234965 - Flags: approval1.8.1?
Comment on attachment 234965 [details] [diff] [review] v3: check for connection refused and expand error codes a=schrep/connor for drivers .
Attachment #234965 - Flags: approval1.8.1? → approval1.8.1+
on branch
Status: NEW → RESOLVED
Closed: 18 years ago
Keywords: fixed1.8.1
Resolution: --- → FIXED
Blocks: 335962
Blocks: 376008
No longer blocks: 376008
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: