Commit 09a7a552 authored by holte's avatar holte Committed by Commit bot

Fix a bug that causes the metrics loop to be broken.

The logs upload loop can be broken if a log upload fails while in state
SENDING_INITIAL_METRICS_LOG.

BUG=441460

Review URL: https://codereview.chromium.org/799613002

Cr-Commit-Position: refs/heads/master@{#308021}
parent 61214232
...@@ -1052,6 +1052,8 @@ void MetricsService::OnLogUploadComplete(int response_code) { ...@@ -1052,6 +1052,8 @@ void MetricsService::OnLogUploadComplete(int response_code) {
ResponseCodeToStatus(response_code), ResponseCodeToStatus(response_code),
NUM_RESPONSE_STATUSES); NUM_RESPONSE_STATUSES);
bool suppress_reschedule = false;
bool upload_succeeded = response_code == 200; bool upload_succeeded = response_code == 200;
// Provide boolean for error recovery (allow us to ignore response_code). // Provide boolean for error recovery (allow us to ignore response_code).
...@@ -1085,6 +1087,7 @@ void MetricsService::OnLogUploadComplete(int response_code) { ...@@ -1085,6 +1087,7 @@ void MetricsService::OnLogUploadComplete(int response_code) {
log_manager_.StageNextLogForUpload(); log_manager_.StageNextLogForUpload();
SendStagedLog(); SendStagedLog();
state_ = SENDING_INITIAL_METRICS_LOG; state_ = SENDING_INITIAL_METRICS_LOG;
suppress_reschedule = true;
} }
break; break;
...@@ -1113,10 +1116,10 @@ void MetricsService::OnLogUploadComplete(int response_code) { ...@@ -1113,10 +1116,10 @@ void MetricsService::OnLogUploadComplete(int response_code) {
// Error 400 indicates a problem with the log, not with the server, so // Error 400 indicates a problem with the log, not with the server, so
// don't consider that a sign that the server is in trouble. // don't consider that a sign that the server is in trouble.
bool server_is_healthy = upload_succeeded || response_code == 400; bool server_is_healthy = upload_succeeded || response_code == 400;
// Don't notify the scheduler that the upload is finished if we've only sent // Don't notify the scheduler that the upload is finished if we've only just
// the initial stability log, but not yet the initial metrics log (treat the // sent the initial stability log, but not yet the initial metrics log (treat
// two as a single unit of work as far as the scheduler is concerned). // the two as a single unit of work as far as the scheduler is concerned).
if (state_ != SENDING_INITIAL_METRICS_LOG) { if (!suppress_reschedule) {
scheduler_->UploadFinished(server_is_healthy, scheduler_->UploadFinished(server_is_healthy,
log_manager_.has_unsent_logs()); log_manager_.has_unsent_logs());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment