fix(site-finder): isolate zone-regulation cache write off the request session (#1850 item 4) #1902
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1902
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/zone-resolver-write-session"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up к #1850 (item 4 — задокументированный SMELL).
Проблема
get_or_fetch_zone_regulationна cache-miss делалupsert_zone_regulation(db, reg)+db.commit()на SHARED request-Session → преждевременно коммитил всю in-flight/analyze-транзакцию (которая по дизайну коммитится РОВНО один раз в конце черезpersist_analysis_run;get_dbна success не коммитит). SAVEPOINT'ы analyze рвались mid-request.Фикс
Апсёрт изолирован в собственную короткую
SessionLocal()(commit/rollback/close) — durable-запись кэша больше не трогает границы tx вызывающего. Read-back по-прежнему через SHARED-сессию (READ COMMITTED видит закоммиченную строку) → форма ответа для callers (parcels.py / ird_analyze.py) не меняется. Канонический паттерн — как вworkers/tasks/zone_regulation_refresh.py.Тесты
test_zone_regulation_write_session.py(новый, 2 кейса: SHARED db.commit НЕ вызывается + fresh-сессия коммитит один раз; table-missing → graceful rollback). Регрессия: memo + backfill + refresh suites — 21 passed. ruff+mypy clean. Backend-only, без schema → codegen не нужен.Refs #1850