Fix additional nested session deadlock in data_processor.py
Root Cause: After fixing the training_service.py deadlock, training progressed to data preparation but got stuck there. The data_processor.py creates another nested session at line 143, updates training_log without committing, causing another deadlock scenario. Session Hierarchy: 1. training_service.py: outer session (fixed ine585e9f) 2. trainer.py: creates own session (passes deadlock due to commit) 3. data_processor.py: creates ANOTHER nested session (THIS FIX) Fix: Added explicit db_session.commit() after progress update in data_processor (line 153) to ensure the UPDATE is committed before continuing with data processing operations that may interact with other sessions. This completes the chain of nested session fixes: -caff497: prophet_manager + hybrid_trainer session passing -e585e9f: training_service commit before trainer call - THIS: data_processor commit after progress update 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -142,13 +142,18 @@ class EnhancedBakeryDataProcessor:
|
||||
# Get database session and repositories
|
||||
async with self.database_manager.get_session() as db_session:
|
||||
repos = await self._get_repositories(db_session)
|
||||
|
||||
|
||||
# Log data preparation start if we have tracking info
|
||||
if job_id and tenant_id:
|
||||
await repos['training_log'].update_log_progress(
|
||||
job_id, 15, f"preparing_data_{inventory_product_id}", "running"
|
||||
)
|
||||
|
||||
# ✅ FIX: Commit the session to prevent deadlock with parent trainer session
|
||||
# The trainer has its own session, so we need to commit this update
|
||||
await db_session.commit()
|
||||
logger.debug("Committed session after data preparation progress update",
|
||||
inventory_product_id=inventory_product_id)
|
||||
|
||||
# Step 1: Convert and validate sales data
|
||||
sales_clean = await self._process_sales_data(sales_data, inventory_product_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user