Skip to content

Commit

Permalink
Merge pull request #753 from Mark-Simulacrum/debug-crater
Browse files Browse the repository at this point in the history
Update rusqlite, increase uncomplete buffer
  • Loading branch information
Mark-Simulacrum authored Dec 8, 2024
2 parents b8aa331 + 2ce425c commit 82aff62
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lazy_static = "1.0"
mime = "0.3.1"
minifier = { version = "0.3", features = ["html"] }
r2d2 = "0.8.2"
rusqlite = { version = "0.29.0", features = ["chrono", "functions", "bundled"] }
rusqlite = { version = "0.32.1", features = ["chrono", "functions", "bundled"] }
rand = "0.8"
regex = "1.0"
reqwest = { version = "0.11", features = ["blocking", "json"] }
Expand Down
7 changes: 6 additions & 1 deletion src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ impl r2d2::ManageConnection for SqliteConnectionManager {
.pragma_update(None, "foreign_keys", "ON")
.unwrap();

// increase the in-memory cache from 2MB to 50MB
connection
.pragma_update(None, "cache_size", "-51200")
.unwrap();

// per docs, this is recommended for relatively long-lived connections (like what we have
// due to the r2d2 pooling)
// https://www.sqlite.org/pragma.html#pragma_optimize
Expand Down Expand Up @@ -114,7 +119,7 @@ impl Database {

fn new(conn: SqliteConnectionManager, tempfile: Option<NamedTempFile>) -> Fallible<Self> {
let pool = Pool::builder()
.connection_timeout(Duration::from_millis(500))
.connection_timeout(Duration::from_secs(5))
.error_handler(Box::new(ErrorHandler))
.build(conn)?;

Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ fn endpoint_next_crate_inner(
let result: Option<crate::crates::Crate> =
if let Some(ex) = Experiment::get(&data.db, &experiment)? {
while let Some(next) = data.uncompleted_cache.lock().unwrap().pop_front() {
if next.0.elapsed() <= std::time::Duration::from_secs(60) {
if next.0.elapsed() <= std::time::Duration::from_secs(120) {
return Ok(Some(next.1));
}
}

let mut crates = ex.get_uncompleted_crates(&data.db, Some(100))?;
let mut crates = ex.get_uncompleted_crates(&data.db, Some(1000))?;
if crates.is_empty() {
None
} else {
Expand Down

0 comments on commit 82aff62

Please sign in to comment.