fix(parcels): SAVEPOINT around velocity → не abort outer tx (analyze 500 fix) #154
1 changed files with 7 additions and 3 deletions
|
|
@ -1808,11 +1808,15 @@ def analyze_parcel(
|
||||||
pipeline_24mo = _aggregate_pipeline(pipeline_rows)
|
pipeline_24mo = _aggregate_pipeline(pipeline_rows)
|
||||||
|
|
||||||
# D2 (#34): velocity-score — темп продаж конкурентов вокруг участка.
|
# D2 (#34): velocity-score — темп продаж конкурентов вокруг участка.
|
||||||
|
# SAVEPOINT защищает outer transaction если velocity SQL падает —
|
||||||
|
# иначе следующие queries (_geotech_risk и пр.) крашатся
|
||||||
|
# с InFailedSqlTransaction.
|
||||||
velocity_data: dict[str, Any] | None = None
|
velocity_data: dict[str, Any] | None = None
|
||||||
try:
|
try:
|
||||||
v_result = compute_velocity(db, parcel_geom_wkt=geom_wkt, radius_km=3.0)
|
with db.begin_nested():
|
||||||
if v_result is not None:
|
v_result = compute_velocity(db, parcel_geom_wkt=geom_wkt, radius_km=3.0)
|
||||||
velocity_data = v_result.as_dict()
|
if v_result is not None:
|
||||||
|
velocity_data = v_result.as_dict()
|
||||||
except Exception as _ve:
|
except Exception as _ve:
|
||||||
logger.warning("velocity compute failed for %s: %s", cad_num, _ve)
|
logger.warning("velocity compute failed for %s: %s", cad_num, _ve)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue