From 3e6ec2fbf71518397353d7ea25bb474ba2278a58 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 27 Apr 2021 17:05:56 -0700 Subject: ingest: cap max body size to ~128 MByte Should resolve 'magic' OOM errors in production. --- python/sandcrawler/ingest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/sandcrawler/ingest.py b/python/sandcrawler/ingest.py index abcc156..eb8e256 100644 --- a/python/sandcrawler/ingest.py +++ b/python/sandcrawler/ingest.py @@ -26,6 +26,8 @@ from sandcrawler.db import SandcrawlerPostgrestClient from sandcrawler.xml import xml_reserialize +MAX_BODY_SIZE_BYTES = 128*1024*1024 + class IngestFileWorker(SandcrawlerWorker): """ High level flow is to look in history first, then go to live web if @@ -576,6 +578,10 @@ class IngestFileWorker(SandcrawlerWorker): result['status'] = 'null-body' return result + if len(resource.body) > MAX_BODY_SIZE_BYTES: + result['status'] = 'body-too-large' + return result + file_meta = gen_file_metadata(resource.body) try: file_meta, resource = fix_transfer_encoding(file_meta, resource) -- cgit v1.2.3