Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable retry for non-iOS builds #120

Draft
wants to merge 2 commits into
base: getsentry
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions handler/crash_report_upload_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ namespace {
// The number of seconds to wait between checking for pending reports.
const int kRetryWorkIntervalSeconds = 15 * 60;

#if BUILDFLAG(IS_IOS)
// The number of times to attempt to upload a pending report, repeated on
// failure. Attempts will happen once per launch, once per call to
// ReportPending(), and, if Options.watch_pending_reports is true, once every
// kRetryWorkIntervalSeconds. Currently iOS only.
// kRetryWorkIntervalSeconds.
const int kRetryAttempts = 5;
#endif

// Wraps a reference to a no-args function (which can be empty). When this
// object goes out of scope, invokes the function if it is non-empty.
Expand Down Expand Up @@ -211,10 +209,8 @@ void CrashReportUploadThread::ProcessPendingReport(
if (ShouldRateLimitUpload(report))
return;

#if BUILDFLAG(IS_IOS)
if (ShouldRateLimitRetry(report))
return;
#endif // BUILDFLAG(IS_IOS)

std::unique_ptr<const CrashReportDatabase::UploadReport> upload_report;
CrashReportDatabase::OperationStatus status =
Expand Down Expand Up @@ -256,7 +252,6 @@ void CrashReportUploadThread::ProcessPendingReport(
report.uuid, Metrics::CrashSkippedReason::kPrepareForUploadFailed);
break;
case UploadResult::kRetry:
#if BUILDFLAG(IS_IOS)
if (upload_report->upload_attempts > kRetryAttempts) {
upload_report.reset();
database_->SkipReportUpload(report.uuid,
Expand All @@ -268,15 +263,6 @@ void CrashReportUploadThread::ProcessPendingReport(
time(nullptr) +
(1 << upload_report->upload_attempts) * kRetryWorkIntervalSeconds;
}
#else
upload_report.reset();

// TODO(mark): Deal with retries properly: don’t call SkipReportUplaod()
// if the result was kRetry and the report hasn’t already been retried
// too many times.
database_->SkipReportUpload(report.uuid,
Metrics::CrashSkippedReason::kUploadFailed);
#endif
break;
}
}
Expand Down Expand Up @@ -417,7 +403,6 @@ bool CrashReportUploadThread::ShouldRateLimitUpload(
return false;
}

#if BUILDFLAG(IS_IOS)
bool CrashReportUploadThread::ShouldRateLimitRetry(
const CrashReportDatabase::Report& report) {
if (retry_uuid_time_map_.find(report.uuid) != retry_uuid_time_map_.end()) {
Expand All @@ -430,6 +415,5 @@ bool CrashReportUploadThread::ShouldRateLimitRetry(
}
return false;
}
#endif

} // namespace crashpad
6 changes: 1 addition & 5 deletions handler/crash_report_upload_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class CrashReportUploadThread : public WorkerThread::Delegate,
//! upload attempts to be retried.
bool ShouldRateLimitUpload(const CrashReportDatabase::Report& report);

#if BUILDFLAG(IS_IOS)
//! \brief Rate-limit report retries.
//!
//! \param[in] report The crash report to process.
Expand All @@ -217,23 +216,20 @@ class CrashReportUploadThread : public WorkerThread::Delegate,
//! rate limit in ShouldRateLimitUpload). When a report upload ends in a retry
//! state, an in-memory only timestamp is stored in |retry_uuid_time_map_|
//! with the next possible retry time. This timestamp is a backoff from the
//! main thread work interval, doubling on each attemt. Because this is only
//! main thread work interval, doubling on each attempt. Because this is only
//! stored in memory, on restart reports in the retry state will always be
//! tried once, and then fall back into the next backoff. This continues until
//! kRetryAttempts is reached.
bool ShouldRateLimitRetry(const CrashReportDatabase::Report& report);
#endif

const Options options_;
const ProcessPendingReportsObservationCallback callback_;
const std::string url_;
const std::string http_proxy_;
WorkerThread thread_;
ThreadSafeVector<UUID> known_pending_report_uuids_;
#if BUILDFLAG(IS_IOS)
// This is not thread-safe, and only used by the worker thread.
std::map<UUID, time_t> retry_uuid_time_map_;
#endif
CrashReportDatabase* database_; // weak
};

Expand Down
Loading