fix(site-finder): db.rollback() в velocity catches + SAVEPOINT zoning/success_rec
velocity.py 3 internal try/except возвращали None БЕЗ db.rollback(). PR #154 SAVEPOINT не помог — exception не propagates из velocity. Postgres tx aborted внутри, cascade InFailedSqlTransaction на следующих queries. Fix: - velocity.py: db.rollback() в 3 catch блоках - parcels.py: SAVEPOINT обёртки для zoning + success_recommendation Refs: user reports 2026-05-15 cascade 500
This commit is contained in:
parent
b13c4be0ed
commit
c3cafefb1a
2 changed files with 76 additions and 57 deletions
|
|
@ -1658,6 +1658,7 @@ def analyze_parcel(
|
||||||
"lon": centroid_lon,
|
"lon": centroid_lon,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
|
with db.begin_nested():
|
||||||
zoning_row = (
|
zoning_row = (
|
||||||
db.execute(
|
db.execute(
|
||||||
text("""
|
text("""
|
||||||
|
|
@ -1692,6 +1693,7 @@ def analyze_parcel(
|
||||||
success_recommendation: dict[str, Any] | None = None
|
success_recommendation: dict[str, Any] | None = None
|
||||||
if district_row:
|
if district_row:
|
||||||
try:
|
try:
|
||||||
|
with db.begin_nested():
|
||||||
success_rows = (
|
success_rows = (
|
||||||
db.execute(
|
db.execute(
|
||||||
text("""
|
text("""
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,13 @@ def compute_velocity(
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("velocity: competitor query failed for wkt=%s", parcel_geom_wkt[:80])
|
logger.exception("velocity: competitor query failed for wkt=%s", parcel_geom_wkt[:80])
|
||||||
|
# КРИТИЧНО: rollback aborted transaction чтобы caller (analyze_parcel)
|
||||||
|
# мог продолжить выполнять последующие queries. Иначе caller получает
|
||||||
|
# cascade InFailedSqlTransaction на следующей SQL execute.
|
||||||
|
try:
|
||||||
|
db.rollback()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not comp_rows:
|
if not comp_rows:
|
||||||
|
|
@ -186,6 +193,11 @@ def compute_velocity(
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("velocity: sale_graph query failed for obj_ids=%s", obj_ids[:5])
|
logger.exception("velocity: sale_graph query failed for obj_ids=%s", obj_ids[:5])
|
||||||
|
# КРИТИЧНО: rollback aborted transaction (см. competitor query комментарий)
|
||||||
|
try:
|
||||||
|
db.rollback()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not sales_rows:
|
if not sales_rows:
|
||||||
|
|
@ -311,6 +323,11 @@ def _get_ekb_median(db: Session, months_window: int = 6) -> float | None:
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning("velocity: ekb_median query failed, using fallback")
|
logger.warning("velocity: ekb_median query failed, using fallback")
|
||||||
|
# КРИТИЧНО: rollback aborted transaction
|
||||||
|
try:
|
||||||
|
db.rollback()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if row and row["median"] is not None:
|
if row and row["median"] is not None:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue