Production restatement hydrates stale non-production snapshot imports
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- data-engineering
Hướng nghiên cứu
Start in sqlmesh/core/plan/common.py, at identify_restatement_intervals_across_snapshot_versions() and the call to get_removal_interval() described in the report. Trace how persisted snapshot interval and model-kind metadata are available, and inspect the related tests for cross-environment restatement cleanup. Done means cleanup avoids rendering or hydrating historical Python and a stale snapshot cannot abort a successful production restatement.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug
plan prod --restate-model ... can fail after a successful production
backfill because RestatementStage loads and renders an unexpired,
non-production historical snapshot with the same model name.
This affects snapshots that import a module which was available when the
snapshot was created but is unavailable in the current production runtime.
SQLMesh version
0.230.1
Current main and release 0.236.2 retain the relevant selection path.
Expected behavior
A production restatement must clear non-production intervals without
executing historical user Python that is unrelated to the production
environment. If historical state cannot hydrate, cleanup must not abort the
successful production restatement.
Actual behavior
identify_restatement_intervals_across_snapshot_versions() finds unexpired
snapshots by model name:
state_reader.get_snapshots_by_names(
snapshot_names=unique_snapshot_names,
current_ts=current_ts,
exclude_expired=True,
)
For full_history_restatement_only snapshots it loads the complete historical
snapshot, calls get_removal_interval(), and renders the stored model.
Rendering hydrates python_env and executes the stored import. A deleted
branch-only module then aborts the production restatement.
Minimal executable reproduction
Install SQLMesh 0.230.1, save this as reproduce.py, and run
python reproduce.py.
from __future__ import annotations
from dataclasses import dataclass
from types import SimpleNamespace
from sqlmesh.core.plan.common import identify_restatement_intervals_across_snapshot_versions
from sqlmesh.core.snapshot import SnapshotId
MODEL_NAME = '"db"."model"'
@dataclass(frozen=True)
class NameVersion:
name: str
version: str
@dataclass(frozen=True)
class IdAndVersion:
snapshot_id: SnapshotId
full_history_restatement_only: bool
@dataclass(frozen=True)
class SnapshotRecord:
identifier: str
version: str
@property
def snapshot_id(self) -> SnapshotId:
return SnapshotId(name=MODEL_NAME, identifier=self.identifier)
@property
def name(self) -> str:
return MODEL_NAME
@property
def name_version(self) -> NameVersion:
return NameVersion(name=MODEL_NAME, version=self.version)
@property
def id_and_version(self) -> IdAndVersion:
return IdAndVersion(self.snapshot_id, True)
@property
def table_info(self) -> SnapshotRecord:
return self
@property
def parents(self) -> list[SnapshotRecord]:
return []
@property
def full_history_restatement_only(self) -> bool:
return True
class HistoricalSnapshot:
def get_removal_interval(self, start: int, end: int) -> tuple[int, int]:
exec("from branch_only_macro import macro")
return start, end
class StateReader:
def __init__(self, old_snapshot: SnapshotRecord) -> None:
self.old_snapshot = old_snapshot
def get_environments_summary(self) -> list[SimpleNamespace]:
return [SimpleNamespace(name="dev")]
def get_environment(self, name: str) -> SimpleNamespace:
return SimpleNamespace(name=name, snapshots=[self.old_snapshot])
def get_snapshots_by_names(self, **_: object) -> list[SnapshotRecord]:
return [self.old_snapshot]
def get_snapshots(self, _: list[SnapshotId]) -> dict[SnapshotId, HistoricalSnapshot]:
return {self.old_snapshot.snapshot_id: HistoricalSnapshot()}
current = SnapshotRecord(identifier="prod", version="current")
historical = SnapshotRecord(identifier="dev", version="old")
identify_restatement_intervals_across_snapshot_versions(
state_reader=StateReader(historical),
prod_restatements={MODEL_NAME: (0, 1)},
disable_restatement_models=set(),
loaded_snapshots={current.snapshot_id: current},
)
Output:
File ".../sqlmesh/core/plan/common.py", line 217,
in identify_restatement_intervals_across_snapshot_versions
new_interval = full_snapshot.get_removal_interval(...)
File "reproduce.py", line 59, in get_removal_interval
exec("from branch_only_macro import macro")
ModuleNotFoundError: No module named 'branch_only_macro'
Suggested direction
Use persisted interval and model-kind metadata to compute removal intervals.
Do not render or hydrate historical snapshot Python during cross-environment
restatement cleanup. At minimum, report an invalid stale snapshot without
aborting the production restatement.
- Ngôn ngữ chính
- Python
- Star
- 3.3k
- Fork
- 471
- Merge trung bình
- 6 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SQLMesh/sqlmesh
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
SQLMesh/sqlmesh#6008 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
VSCode Extension: SQLMesh LSP crashes on startup: ImportError: cannot import name 'WorkspaceDiagnosticRefreshRequest' with lsprotocol 2025.xCó thể đã có người làm @boomesh11 đã nhận 15 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Improvement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
SQLMesh/sqlmesh#5696 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của SQLMesh/sqlmesh
Issue tương tự
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Có thể đã có người làm @sumitkhond111-del đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
open-mmlab/mmcv#3352 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
OpenGithubs/weekly#263 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
comp/cli P3 type/feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
NousResearch/hermes-agent#162784 ·
Maintainer thường phản hồi trong vòng 1 ngày