A fork of attic a self-hostable Nix Binary Cache server
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #116 from ixmatus/parnell/fix-gc-bug

gc.rs: `LIMIT` number of `orphan_chunks`, fixes #115

authored by

Zhaofeng Li and committed by
GitHub
3907b311 4dbdbee4

+10
+10
server/src/gc.rs
··· 158 158 let db = state.database().await?; 159 159 let storage = state.storage().await?; 160 160 161 + let orphan_chunk_limit = match db.get_database_backend() { 162 + // Arbitrarily chosen sensible value since there's no good default to choose from for MySQL 163 + sea_orm::DatabaseBackend::MySql => 1000, 164 + // Panic limit set by sqlx for postgresql: https://github.com/launchbadge/sqlx/issues/671#issuecomment-687043510 165 + sea_orm::DatabaseBackend::Postgres => u64::from(u16::MAX), 166 + // Default statement limit imposed by sqlite: https://www.sqlite.org/limits.html#max_variable_number 167 + sea_orm::DatabaseBackend::Sqlite => 500, 168 + }; 169 + 161 170 // find all orphan chunks... 162 171 let orphan_chunk_ids = Query::select() 163 172 .from(Chunk) ··· 190 199 191 200 let orphan_chunks: Vec<chunk::Model> = Chunk::find() 192 201 .filter(chunk::Column::State.eq(ChunkState::Deleted)) 202 + .limit(orphan_chunk_limit) 193 203 .all(db) 194 204 .await?; 195 205