max / makenotwork
1 file changed,
+7 insertions,
-3 deletions
| @@ -168,11 +168,15 @@ async fn run_pipeline_and_decide( | |||
| 168 | 168 | return Ok(FileScanStatus::HeldForReview); | |
| 169 | 169 | } | |
| 170 | 170 | ||
| 171 | - | // Permit + S3 download + scan. Permit drops before the tail ops to avoid | |
| 172 | - | // serializing on small post-scan work. | |
| 171 | + | // S3 download runs *outside* the scan_semaphore. The permit bounds the | |
| 172 | + | // CPU/clamd-heavy scan phase, not network IO — holding it across the GET | |
| 173 | + | // serializes downloads at SCAN_MAX_CONCURRENT and lets a scan backlog | |
| 174 | + | // starve the DB pool. Worker count is the operational cap on concurrent | |
| 175 | + | // downloads. | |
| 176 | + | let data = ctx.s3.download_object(&job.s3_key).await?; | |
| 177 | + | ||
| 173 | 178 | let result: ScanResult = { | |
| 174 | 179 | let _permit = ctx.scan_semaphore.acquire().await?; | |
| 175 | - | let data = ctx.s3.download_object(&job.s3_key).await?; | |
| 176 | 180 | Arc::clone(&ctx.pipeline).scan(data, file_type).await | |
| 177 | 181 | }; | |
| 178 | 182 |