Skip to content

Commit 1cce32e

Browse files
Increase database connection pool
sqlite shouldn't actually care about the number of open connections, and it's not clear that we need a pool at all, but this seems like it may resolve the issues we're seeing timing out acquiring a connection.
1 parent e9ba336 commit 1cce32e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/db/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ impl Database {
120120

121121
fn new(conn: SqliteConnectionManager, tempfile: Option<NamedTempFile>) -> Fallible<Self> {
122122
let pool = Pool::builder()
123-
.connection_timeout(Duration::from_secs(5))
123+
// By inspection we have 13 threads in production, so make sure each of them can get a
124+
// connection. In practice some of those wouldn't acquire database connections (e.g.,
125+
// the ctrl-c thread) but this seems like a good idea regardless.
126+
.max_size(20)
127+
.connection_timeout(Duration::from_secs(30))
124128
.error_handler(Box::new(ErrorHandler))
125129
.build(conn)?;
126130

0 commit comments

Comments
 (0)