Repository navigation
fix: reject invalid global time_zone, save DATA BRANCH DIFF temporal results, reject snapshot-qualified write targets - #32456
Conversation
SET GLOBAL time_zone stored any string, and every new session then failed to initialize with "unknown time zone", even after a restart. Extract the parsing of updateTimeZone into resolveTimeZone and call it from SetGlobalSysVar, so an unknown zone is rejected like SET SESSION does. Fixes matrixorigin#31714 (cherry picked from commit a8dfd88)
DATA BRANCH DIFF renders its rows as text. With save_query_result=on, convertRowsIntoBatch asserted DATE/TIME/DATETIME cells to MatrixOne values and panicked on the text (service crash), dropped the declared fractional-second scale of TIME/DATETIME/TIMESTAMP columns, and parsed TIMESTAMP text in the process zone instead of the session zone. Parse DATE/TIME/DATETIME text, keep the column scale from the result column definition, and read TIMESTAMP text in the session time zone. Fixes matrixorigin#31547 Fixes matrixorigin#31550 (cherry picked from commit 4556f67)
A {snapshot=...}/{timestamp=...} qualifier on an INSERT/REPLACE/UPDATE/DELETE
target or an ALTER/TRUNCATE/DROP TABLE name was ignored and the statement
modified the live table. Reject such targets at plan time; snapshot-qualified
tables stay valid as read sources.
Fixes matrixorigin#31688
(cherry picked from commit 375cf9b)
- an unqualified SET column of a multi-table UPDATE now counts as a write to the snapshot-qualified table that has that column; - LOAD DATA, INSERT ALL, CREATE INDEX, DROP INDEX and RENAME TABLE on a snapshot-qualified table are rejected as well; - alias matching is case-sensitive under lower_case_table_names=0. Adds unit coverage for each case with controls. (cherry picked from commit 768ace7)
- snapshot write-target guard: pass the TableResolution argument that CompilerContext.Resolve now takes. - merge the matrixorigin#31714 and matrixorigin#31547/matrixorigin#31550 frontend unit tests into one file and the three BVT cases into util/priority_fixes_31547_31688_31714 to keep the combined PR within 10 files.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Queue requested — the merge queue status continues in this comment ↓. |
… baseline The existing float-switch exemption moved with the function body to convertRowsIntoBatchInLocation; no switch is added.
… baseline entry Result columns come from mysqlColDef2PlanResultColDef, which only yields T_float32/T_float64, so the partial float switch is intended. Restore the baseline entry rather than renaming it.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 86d6fbf32cfb96ed8e0155d6124cec3e568ae4cb
Assessment: approve
The three fixes close the reported write-target and temporal-result failures and reject invalid global timezones before persistence. Shared timezone and temporal parsers remain authoritative; the targeted planning guard preserves historical read sources without adding persistent state. No actionable correctness or design findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Read the complete ten-file delta, all discussion entries and all four linked issues, including the TIME follow-up. Traced global persistence/session initialization, temporal rendering/saved-result readback, and DML/DDL target binding through PREPARE and EXPLAIN.
-
Reused frozen-head evidence.json CI successes for shared build, Ubuntu/x86 UT, arm64 SCA, UT coverage, and PROXY/PESSIMISTIC BVT. Reviewed the new UT and SQL oracles for precision, session timezone, NULLs, unchanged globals/live tables and permitted historical read sources.
-
Local git diff --check passed for 71390fb..86d6fbf; receipt checks/1794641118143085628-2.json, retained output diff-check.log and validation-record.json.
Limitations:
-
No fresh local Go or cluster execution. Captured CI conclusions are reused; raw CI/author logs are unavailable, and author-reported baseline experiments and statement counts were not independently replayed.
-
The timezone change prevents new invalid global settings; it does not repair already-invalid persisted values or change the existing unknown-zone error code.
✅ Merged into
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31714
Fixes #31547
Fixes #31550
Fixes #31688
What this PR does / why we need it:
把此前被关闭、未合入的三个修复中影响最大的几项(锁死登录、进程崩溃、静默写错表)合成一个 PR,基于当前 main(
11d2e1ef)重新整理。三项修复的代码互不重叠:SET GLOBAL time_zone写入非法时区后,所有新连接都无法登录(原 fix(frontend): validate SET GLOBAL time_zone before persisting it #31830)SET GLOBAL time_zone = 'Mars/Phobos'返回 OK 并持久化,之后每个新连接都报1815 unknown time zone,重启也不能恢复。updateTimeZone的校验抽成resolveTimeZone,SetGlobalSysVar在持久化time_zone之前先用它校验。非法值直接报错,和SET SESSION的行为一致。pkg/frontend/variables.go、pkg/frontend/types.gosave_query_result = on时,DATA BRANCH DIFF遇到 DATETIME/TIME 列会让服务进程崩溃;TIMESTAMP 丢精度、时区不对(原 fix(frontend): parse temporal text when saving DATA BRANCH DIFF results #31842)convertRowsIntoBatch对types.Datetime/Time/Date做类型断言,直接 panic,整个 CN 退出。pkg/frontend/util.go、pkg/frontend/query_result.got{snapshot='sp'}执行 DML/DDL 会静默改动当前表(原 fix(plan): reject DML/DDL that targets a snapshot-qualified table #31854)INSERT/UPDATE/DELETE/ALTER/TRUNCATE/DROP ... t{snapshot='sp'}都返回成功,实际写进了当前表,快照不变,也没有任何提示。BuildPlan入口新增rejectSnapshotQualifiedWriteTarget。写入目标带快照/时间戳限定时,统一报not supported: <OP> on a snapshot-qualified table。覆盖的语句有 INSERT、REPLACE、UPDATE(含多表)、DELETE(含多表)、ALTER、TRUNCATE、DROP TABLE、LOAD、INSERT ALL、CREATE/DROP INDEX、RENAME。带快照限定的表作为只读来源(INSERT ... SELECT、UPDATE/DELETE 的 JOIN 来源)不受影响。pkg/sql/plan/build.go、pkg/sql/plan/snapshot_write_target.goHow this PR does it or why it needs it:
CompilerContext.Resolve现在多了一个*TableResolution参数,相应补上nil。pkg/frontend/time_zone_and_saved_temporal_test.go,三组 BVT 合并成test/distributed/cases/util/priority_fixes_31547_31688_31714.{sql,result}。用例内容不变,按 issue 分段注释。Evidence(本地,main
11d2e1ef对比本分支)unshare -rn隔离网络):DATA BRANCH DIFF c AGAINST b后客户端报 2013,服务进程退出;本分支正常返回c, UPDATE, 1, 2024-01-02 00:00:00.654321, 04:05:06.654321, ...,服务存活。INSERT INTO snap_t{snapshot='sp'} ...成功,当前表多出一行;本分支报20105 not supported: INSERT on a snapshot-qualified table 'snap_t',当前表不变。SET GLOBAL time_zone='Mars/Phobos'成功,之后新连接报1815 unknown time zone Mars/Phobos;本分支 SET 时直接报错,全局值仍是SYSTEM,新连接正常。util/priority_fixes_31547_31688_31714.sql:本分支 57/57 通过;main 13/57(DIFF 让进程崩溃后,后续 40 条全部 ABNORMAL)。system_variable636/636,git4data/branch/diff1976/1976,结果与 main 相同。snapshot18389/18454:65 条失败全部在snapshot_restore_account_level.sql,原因是本机资源准入报execution resource admission rejected ... cap=0,与本改动无关,main 在同一目录也出现同类资源错误。全目录没有任何语句命中新的 snapshot-qualified 报错。go test ./pkg/frontend/ ./pkg/sql/plan/全部通过(含新增的TestSetGlobalTimeZoneRejectsUnknownZone、TestConvertRowsIntoBatchTemporalText和 snapshot write-target 用例)。go vet、molint check、golangci-lint v2.14.0 -c .golangci.yml --new-from-rev=origin/main(./pkg/frontend/...、./pkg/sql/plan/)均无问题。Special notes for your reviewer:
unknown time zone ...),没有改成 MySQL 的 1298,以免改变会话级的既有行为。