Skip to content

[Bug]: max_execution_time is accepted but not enforced, breaking ODBC query timeout #26678

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Related feature request: #23361
ODBC umbrella issue: #26677

Branch Name

m-25908

Commit ID

35252dd

The running server reports 8.0.30-MatrixOne-v25908.

Other Environment Information

  • Hardware parameters: Apple Silicon ARM64, 10 logical CPUs
  • OS type: macOS 15.5, Darwin 24.5.0
  • Deployment: fresh local launch with etc/launch/launch.toml
  • Client: MySQL client 9.7.1 and MatrixOne ODBC derived from MySQL Connector/ODBC 9.7.0

Actual Behavior

MatrixOne accepts a session max_execution_time value and returns it through the system variable, but does not enforce the limit.

With max_execution_time set to 500 milliseconds, SELECT sleep(2) returns successfully after approximately 2.01 seconds.

This breaks ODBC SQL_ATTR_QUERY_TIMEOUT. MySQL Connector/ODBC implements that ODBC attribute by executing set @@max_execution_time=<seconds * 1000>. The upstream t_query_timeout ODBC test therefore runs past its configured deadline against MatrixOne.

The behavior is especially problematic for BI clients because the timeout configuration appears to succeed. Applications cannot distinguish it from a working server-side deadline until a query runs indefinitely.

Expected Behavior

For a read-only SELECT, a nonzero max_execution_time should terminate execution near the configured millisecond limit and return a query-interrupted error to the client.

If MatrixOne does not support this variable yet, setting it should fail explicitly instead of accepting and ignoring it. Silent acceptance must not imply timeout enforcement.

Steps to Reproduce

Run against a fresh MatrixOne instance:

/usr/bin/time -p env MYSQL_PWD=111 mysql \
  --protocol=tcp -h 127.0.0.1 -P 6001 -u root \
  -Nse "set @@max_execution_time=500; select @@max_execution_time; select sleep(2);"

Observed output:

500
0
real 2.01
user 0.00
sys 0.00

ODBC reproduction:

  1. Connect using MatrixOne ODBC or MySQL Connector/ODBC.
  2. Set SQL_ATTR_QUERY_TIMEOUT to 2 on a statement.
  3. Execute a read-only query that takes longer than 2 seconds.
  4. The attribute setter succeeds, but the query continues beyond the deadline.

Additional information

Relevant MySQL Connector/ODBC behavior is in driver/utility.cc: set_query_timeout converts seconds to milliseconds and sends set @@max_execution_time=.

Suggested server regression coverage:

  • zero means no deadline;
  • a positive value interrupts SELECT sleep or another deterministic long query;
  • the timeout is session scoped;
  • a timed-out statement does not poison the connection or transaction;
  • changing and resetting the value affects subsequent statements;
  • the client receives a stable native error suitable for ODBC SQLSTATE mapping.

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions