Repository navigation
Closed
Closed
Bug
Copy link
Labels
kind/bugSomething isn't workingphase/testingseverity/s1High impact: Logical errors or data errors that must occur
Milestone
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Deployment: GitHub Actions regression environment
- Client: MOTR/PyMySQL, one persistent connection for the complete test case
- Test date: 2026-08-12
Actual Behavior
A user-defined variable assigned from a TIMESTAMP scalar subquery disappears before a later statement on the same connection.
The assignment itself succeeds, but both later reads fail:
ERROR 20101: internal error: the user variable ts0 does not exist
The MOTR case reported stmts=101 ok=99 fail=2. The only failed statements were the two later reads of @ts0; the preceding SET @ts0 = (...) was counted as successful.
Expected Behavior
After a successful SET @ts0 = (...), @ts0 must remain available for subsequent statements on the same session until it is overwritten, explicitly cleared, or the connection is closed.
The equality check should return 1, and the later update check should return 99, 1.
Steps to Reproduce
drop database if exists repro_user_var_timestamp;
create database repro_user_var_timestamp;
use repro_user_var_timestamp;
create table r9(
id int primary key,
v int,
updated_at timestamp default current_timestamp on update current_timestamp
);
insert into r9(id, v) values (1, 10);
set @ts0 = (select updated_at from r9 where id = 1);
-- Wait two seconds on the client without reconnecting.
insert into r9(id, v) values (1, 10)
on duplicate key update v = v;
select updated_at = @ts0 as ts_unchanged from r9 where id = 1;
insert into r9(id, v) values (1, 99)
on duplicate key update v = values(v);
select v, updated_at > @ts0 as ts_advanced from r9 where id = 1;Additional information
Stability and control
- Bad commit
eee0ae09ede93072615315a6fe24469550b5be9a: the case failed with99/101statements passing. - Control commit
fe62a8fd83d29b829070f9bf8ea21b2332e8a35a: the exact case passed with101/101statements. - MOTR commits
fa50a88c70e7d4cc592552a8e5d127b7e90f1537and25ef8a4c96ce517113ec22cf12d863f1f13ded3fhave identical trees. - Both runs used
mainand the same MOTR command. - MOTR's
--sleep 2only sleeps and does not reconnect. ItsNamedConnreuses the same PyMySQL connection for all statements in this case.
Evidence
- Failing job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31602163670/job/94138171639
- Passing control job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31588954191/job/94100709837
- Failing case:
10_optimizer.issue24907_replace_odku_affected_rows
Related
- Found while running the regression derived from [Bug]: REPLACE / INSERT ... ON DUPLICATE KEY UPDATE report non-MySQL affected-rows #24907, but this is a separate session-variable regression rather than a recurrence of its affected-rows defect.
- [Bug]: Reading an undefined user variable @x errors instead of returning NULL; SELECT … INTO @var rejected #25123 tracks undefined user-variable and
SELECT ... INTO @varcompatibility. This issue is different becauseSET @ts0 = (...)succeeds before the assigned variable disappears.
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingphase/testingseverity/s1High impact: Logical errors or data errors that must occur
Activity
VioletQwQ-0 commentedon Aug 14, 2026
Triage result: severity/s1. A deterministic current-main regression now confirms that connection migration does not export evaluated user-defined variables. The defect is topology-dependent (multi-CN through Proxy) and can produce stable session-state loss, while isolated single-CN controls pass. There is currently no evidence of persistent data corruption, cross-tenant impact, or a broad customer/POC outage, so s0 is not justified. Escalate if such evidence appears.
VioletQwQ-0 commentedon Aug 19, 2026
PR #27180 已合并,关联 issue 仍需 QA 验证,暂不关闭。
a012f5d6973dcc58e73ac445871814b43353fe78main:6f42b19508f31ef04ae2857172893f13d48afddf请在当前
main@6f42b19508f31ef04ae2857172893f13d48afddf上验证 2+ CN、双 Proxy、开启 connection cache 和 prepared short connections 的部署,强制触发后端迁移,并执行 issue 的串行/并行 MOTR 场景。重点确认 TIMESTAMP scalar-subquery 产生的用户变量在迁移后仍存在且值一致,同时检查 prepared statements、事务隔离、系统变量和ROW_COUNT()状态;还需确认无登录失败、panic/restart、后端/session 泄漏或迁移静默成功但状态丢失。请用包含版本、拓扑、准确 SQL/结果及终态计数的证据回复。预期 PASS 是迁移和连接复用成功且上述 session 状态保持一致;任何状态丢失、迁移错误或稳定性异常都应保留 issue OPEN 并标记
test-verification-failed。tester 选择依据:issue author.login 为
Ariznawlll,按约定选择Ariznawlll;当前自动化账号VioletQwQ-0将不保留在 assignees 中。Ariznawlll commentedon Aug 24, 2026
测试版本
mainba8954d543af0bdfb1948a8b89f77f5235ac9259原问题验证
按 Issue 中的原始顺序执行:从
TIMESTAMP标量子查询给会话变量赋值,等待两秒后执行重复键 no-op 更新,再执行把v更新为99的重复键语句。连续 3 轮均得到ts_unchanged=1,随后得到v=99, ts_advanced=1;会话变量在两次后续语句中均仍可读取。Happy Path 覆盖
99,时间值相对保存值前进。Unhappy Path 覆盖
白盒验证
不适用:该问题可由公开 SQL 在单连接内稳定覆盖,未使用内部注入。
回归测试
issue_27054_timestamp_variable_persistence.test。33/33语句成功。测试证据
ts_unchanged=1,v=99, ts_advanced=1。a6a562a1。测试结论
测试通过。