fix: add db.rollback() to prevent session state corruption during historical import
When create_letzshop_order raises an exception (e.g., product not found by GTIN) after flushing the order to the database, the session is left in an inconsistent state. Without rollback, subsequent database operations fail or hang, causing the import to get stuck at "0 processed...". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -711,6 +711,10 @@ class LetzshopOrderService:
|
||||
self.create_order(vendor_id, shipment)
|
||||
stats["imported"] += 1
|
||||
except Exception as e:
|
||||
# Rollback session to clear any partial changes from failed order
|
||||
# This is crucial because create_letzshop_order may have flushed
|
||||
# the order before the exception was raised (e.g., product not found)
|
||||
self.db.rollback()
|
||||
stats["errors"] += 1
|
||||
stats["error_messages"].append(
|
||||
f"Shipment {shipment_id}: {str(e)}"
|
||||
|
||||
Reference in New Issue
Block a user