Skip to content

Commit d6786f1

Browse files
committed
sharepoint memory issue debugging
1 parent c558732 commit d6786f1

File tree

4 files changed

+429
-36
lines changed

4 files changed

+429
-36
lines changed

backend/onyx/background/celery/tasks/docprocessing/tasks.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
from onyx.redis.redis_utils import is_fence
101101
from onyx.server.runtime.onyx_runtime import OnyxRuntime
102102
from onyx.utils.logger import setup_logger
103+
from onyx.utils.memory_logger import log_memory_usage
103104
from onyx.utils.middleware import make_randomized_onyx_request_id
104105
from onyx.utils.telemetry import optional_telemetry
105106
from onyx.utils.telemetry import RecordType
@@ -1279,6 +1280,10 @@ def _docprocessing_task(
12791280
f"batch_num={batch_num} "
12801281
)
12811282

1283+
log_memory_usage(
1284+
f"docprocessing_task:start:batch_{batch_num}:attempt_{index_attempt_id}"
1285+
)
1286+
12821287
# Get the document batch storage
12831288
storage = get_document_batch_storage(cc_pair_id, index_attempt_id)
12841289

@@ -1297,7 +1302,16 @@ def _docprocessing_task(
12971302
per_batch_lock: RedisLock | None = None
12981303
try:
12991304
# Retrieve documents from storage
1305+
log_memory_usage(
1306+
f"docprocessing_task:before_load_batch_{batch_num}:attempt_{index_attempt_id}"
1307+
)
13001308
documents = storage.get_batch(batch_num)
1309+
log_memory_usage(
1310+
f"docprocessing_task:after_load_batch_{batch_num}:attempt_{index_attempt_id}",
1311+
documents,
1312+
f"batch_{batch_num}_documents",
1313+
)
1314+
13011315
if not documents:
13021316
task_logger.error(f"No documents found for batch {batch_num}")
13031317
return
@@ -1369,6 +1383,12 @@ def _docprocessing_task(
13691383
f"Processing {len(documents)} documents through indexing pipeline"
13701384
)
13711385

1386+
log_memory_usage(
1387+
f"docprocessing_task:before_indexing_pipeline:batch_{batch_num}:attempt_{index_attempt_id}",
1388+
documents,
1389+
f"batch_{batch_num}_documents_before_pipeline",
1390+
)
1391+
13721392
# real work happens here!
13731393
index_pipeline_result = run_indexing_pipeline(
13741394
embedder=embedding_model,
@@ -1381,6 +1401,12 @@ def _docprocessing_task(
13811401
index_attempt_metadata=index_attempt_metadata,
13821402
)
13831403

1404+
log_memory_usage(
1405+
f"docprocessing_task:after_indexing_pipeline:batch_{batch_num}:attempt_{index_attempt_id}",
1406+
index_pipeline_result,
1407+
f"batch_{batch_num}_pipeline_result",
1408+
)
1409+
13841410
# Update batch completion and document counts atomically using database coordination
13851411

13861412
with get_session_with_current_tenant() as db_session, cross_batch_db_lock:
@@ -1458,7 +1484,14 @@ def _docprocessing_task(
14581484
f"elapsed={elapsed_time:.2f}s"
14591485
)
14601486

1487+
log_memory_usage(
1488+
f"docprocessing_task:completed:batch_{batch_num}:attempt_{index_attempt_id}"
1489+
)
1490+
14611491
except Exception:
1492+
log_memory_usage(
1493+
f"docprocessing_task:exception:batch_{batch_num}:attempt_{index_attempt_id}"
1494+
)
14621495
task_logger.exception(
14631496
f"Document batch processing failed: "
14641497
f"batch_num={batch_num} "

0 commit comments

Comments
 (0)