Skip to content

Fix panics when building a crate from the queue #862

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

Merged
merged 2 commits into from
Jun 29, 2020
Merged
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
17 changes: 9 additions & 8 deletions src/docbuilder/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,24 @@ impl DocBuilder {
.get(0))
}

/// Builds the top package from the queue. Returns whether the queue was empty.
/// Builds the top package from the queue. Returns whether there was a package in the queue.
///
/// Note that this will return `Ok(true)` even if the package failed to build.
pub(crate) fn build_next_queue_package(
&mut self,
builder: &mut RustwideBuilder,
) -> Result<bool> {
// This is in a nested scope to drop the connection before build_package is called,
// otherwise the borrow checker will complain.
let (id, name, version): (i64, String, String) = {
let (id, name, version): (i32, String, String) = {
let conn = self.db.get()?;

let query = conn.query(
"SELECT id, name, version
FROM queue
WHERE attempt < 5
ORDER BY priority ASC, attempt ASC, id ASC
LIMIT 1",
FROM queue
WHERE attempt < 5
ORDER BY priority ASC, attempt ASC, id ASC
LIMIT 1",
&[],
)?;

Expand All @@ -105,7 +107,6 @@ impl DocBuilder {
let conn = self.db.get()?;

let _ = conn.execute("DELETE FROM queue WHERE id = $1", &[&id]);
crate::web::metrics::TOTAL_BUILDS.inc();
}
Err(e) => {
let conn = self.db.get()?;
Expand All @@ -118,7 +119,6 @@ impl DocBuilder {
let attempt: i32 = rows.get(0).get(0);
if attempt >= 5 {
crate::web::metrics::FAILED_BUILDS.inc();
crate::web::metrics::TOTAL_BUILDS.inc();
}
error!(
"Failed to build package {}-{} from queue: {}\nBacktrace: {}",
Expand All @@ -130,6 +130,7 @@ impl DocBuilder {
}
}

crate::web::metrics::TOTAL_BUILDS.inc();
Ok(true)
}
}