fix(scrapers): commit outer tx в domrf_catalog scrape_catalog_batch (#1227)
All checks were successful
CI / changes (pull_request) Successful in 8s
CI / changes (push) Successful in 6s
CI / frontend-tests (pull_request) Has been skipped
CI / frontend-tests (push) Has been skipped
CI / backend-tests (pull_request) Successful in 6m27s
CI / backend-tests (push) Successful in 6m29s
All checks were successful
CI / changes (pull_request) Successful in 8s
CI / changes (push) Successful in 6s
CI / frontend-tests (pull_request) Has been skipped
CI / frontend-tests (push) Has been skipped
CI / backend-tests (pull_request) Successful in 6m27s
CI / backend-tests (push) Successful in 6m29s
begin_nested() лишь RELEASE'ит SAVEPOINT — без db.commit() все UPDATE цен откатывались при db.close() в Celery task. Зеркалит правильный паттерн scrape_catalog_objects (domrf_catalog_object.py:460): try- commit/except-rollback в конце функции. 50 catalog тестов зелёные. Closes #1227
This commit is contained in:
parent
06c4bb9fd6
commit
141873d061
1 changed files with 11 additions and 0 deletions
|
|
@ -553,6 +553,17 @@ async def scrape_catalog_batch(
|
|||
else:
|
||||
stats["failed"] += 1
|
||||
|
||||
# Commit outer transaction: SAVEPOINT (`begin_nested`) в upsert_catalog_data
|
||||
# лишь RELEASE'ит внутренний SAVEPOINT, но outer tx остаётся autobegin'd —
|
||||
# без commit() все UPDATE'ы (цены, отделка, catalog_updated_at) откатятся
|
||||
# при db.close() в Celery task. Зеркалит scrape_catalog_objects в
|
||||
# domrf_catalog_object.py:460. Issue #1227.
|
||||
try:
|
||||
db.commit()
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
|
||||
logger.info(
|
||||
"scrape_catalog_batch done: total=%d success=%d failed=%d fields_total=%d",
|
||||
stats["total"],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue