Repository navigation
Description
DRAFT 26 (SDK, 2026-10-27) — filing now
Title: [Bug]: Snapshot timestamps parsed with local-timezone fromtimestamp (naive local datetime, off by UTC offset); exists() swallows all errors as "not exists"
Description
Two defects in the snapshot manager family (matrixone/snapshot.py):
1. _parse_snapshot_row renders snapshot times in the machine's local timezone
timestamp = datetime.fromtimestamp(row[1] / 1_000_000_000) # naive LOCAL timedatetime.fromtimestamp(x) with no tz argument produces a timezone-naive datetime in the host's local timezone. The snapshot's creation instant (nanoseconds since epoch from the server) is thus displayed as whatever the SDK host's TZ happens to be — a user in UTC+8 sees timestamps 8 hours ahead of a user in UTC for the same snapshot, and neither value is labeled as naive-local. Snapshot.created_at flows into every list/get result and into REST/tooling output.
Correct forms: datetime.fromtimestamp(x, tz=timezone.utc) (aware UTC) — or at minimum aware-local — but an unaware local rendering is the one option that cannot be reasoned about by consumers.
2. exists() translates every error into "False"
def exists(self, name):
try:
self.get(name); return True
except SnapshotError:
return Falseget() wraps any failure (connection error, permission error, SHOW SNAPSHOTS parse failure, transient server error) into SnapshotError. exists() therefore reports False for snapshots that do exist whenever anything else goes wrong. Callers branch on this weakly-typed boolean everywhere — including clone_database_with_snapshot/clone_table_with_snapshot which pre-flight check via snapshots.exists(...) and refuse valid operations, and restore_* paths. A transient blip turns into "snapshot does not exist", which misleads operators into re-creating snapshots or abandoning restores.
3. (family addendum) CREATE SNAPSHOT interpolates name/database/table raw
f"CREATE SNAPSHOT {name} FOR DATABASE {database}" — no escaping at all (not even the no-op helpers used elsewhere); one more member of the escaping family consolidated by today's other issues.
Reproduction
import datetime
# 1) timezone:
ts = datetime.datetime(2026, 10, 27, 5, 0, 0, tzinfo=datetime.timezone.utc).timestamp()
row_like = ts * 1e9
print(datetime.datetime.fromtimestamp(row_like / 1e9)) # local-time rendering — differs per host TZ
print(datetime.datetime.fromtimestamp(row_like / 1e9, tz=datetime.timezone.utc)) # the intent
# 2) exists(): with a dead/permission-limited connection the manager returns FalseImpact
- Timezone: every GUI/CLI consuming
Snapshot.created_atshows drift by the host offset; cross-region teams see "snapshots created in the future/past". Silent, permanent, and the kind of thing that corrupts audit trails. - exists(): flaky infrastructure anywhere exists() gates operations — the class of false-negative that breaks restore automation and wastes on-call hours.
Expected behavior
- Parse with
tz=timezone.utc(or return aware local with explicit tz attribute), and document the returned value; library-wide test hosts set different TZs (envTZ=) to lock behavior. exists()should distinguishSnapshotNotFound(a dedicated exception) from infra errors — infra errors must propagate (or be logged + raise), not masquerade as presence/absence.- Escape snapshot/db/table names in CREATE (family fix).
Activity
fix(python): unify SDK query and analytics lifecycle contracts (#31774)
XuPeng-SH commentedon Oct 30, 2026
QA handoff for merged #31774 (main
bbfe55669a1440424914d45a283a1d0e36f722fa): please verify the reported public SDK contract and its failure/recovery controls for snapshot created_at parsed as naive local datetime; exists() maps every error to False. This isolated QA run inspected the issue and merged PR but did not run tests or a live MatrixOne service at this SHA because the existing resource guard left insufficient headroom. The PR's author-reported validation is separate evidence, not a result of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。快照时间按 UTC 返回,真实不存在的快照与连接异常被区分,同步和异步接口均符合预期。
关键证据
main@d39d8a40343ccd40bf665036388df7a40ee867f8;修复 PR fix(python): unify SDK query and analytics lifecycle contracts #31774 合并提交bbfe55669a1440424914d45a283a1d0e36f722fa在该版本祖先链。运行二进制和 SDK 源码同完整 SHA;本地隔离 1 CN / 1 TN / 1 LogService,Python 3.12。待解决点
Ariznawlll commentedon Oct 30, 2026
回归位置更正:#295 已关闭并汇总至 MOTR #298,该 issue 的定向用例已包含在 #298。此前测试证据与未覆盖项不变;#298 尚未合入,完整 MOTR suite 未运行。