Skip to content

handle strings size is bigger than 16mb #2635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dev_utils/mongo_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

from pymongo import UpdateOne, errors
from bson import BSON

from dev_utils.mongodb import (
mongo_bulk_write,
Expand Down Expand Up @@ -68,6 +69,11 @@ def normalize_file(file_dict, task_id):

new_dict["_id"] = key
file_dict[FILE_REF_KEY] = key
# 16MB limit handling
strings_val = new_dict.get("strings")
if strings_val and len(BSON.encode({"strings": strings_val})) > 15 * 1024 * 1024:
log.warning("strings field is too large (>15MB), truncating to avoid MongoDB document size error")
new_dict["strings"] = []
return UpdateOne({"_id": key}, {"$set": new_dict, "$addToSet": {TASK_IDS_KEY: task_id}}, upsert=True, hint=[("_id", 1)])


Expand Down
Loading