tencent cloud

TencentDB for MySQL

DocumentationTencentDB for MySQLKernel FeaturesChecking and Fixing Kernel IssuesIssue with SEL_ARG Red-Black Tree Operations in the MySQL 5.7 Range Optimizer

Issue with SEL_ARG Red-Black Tree Operations in the MySQL 5.7 Range Optimizer

Download
Focus Mode
Font Size
Last updated: 2026-07-02 10:33:18
AI-Translated

Issue

An issue exists in the Red-Black Tree operations of the SEL_ARG structure within the Range Optimizer of MySQL 5.7, causing the primary database to Crash.

Issue Triggering Scenarios

1. Background: MySQL Official Bug: #112129.
2. The table contains multiple composite indexes that involve overlapping columns.
3. The WHERE clause contains a large number of nested IN/NOT IN/OR conditions.
4. The Range Optimizer is triggered by operations such as SELECT, EXPLAIN SELECT, UPDATE, and DELETE.

Affected Kernel Versions

All kernel versions of MySQL 5.7.

Fixed Kernel Version

MySQL 8.0 versions 20201230 and later.

Fixing Methods

Long-Term Solution (Recommended)

Upgrade the kernel version to MySQL 8.0 version 20201230 or later. For the operation method, see Upgrading from MySQL 5.7 to MySQL 8.0 and Upgrading the Kernel Minor Version.

Emergency Workaround

UNION ALL Splitting: Complex multi-layer OR conditions are split into multiple simple subqueries and combined using UNION ALL. Each subquery contains only AND + IN conditions and does not trigger key_or() recursion.
SQL Rewriting Reference:
SELECT C2 FROM(
-- Branch 1: c6='V6' AND C4='25' AND C5 IN(...) AND c7='v7a'
SELECT C2 FROM t1
WHERE C2 IS NOT NULL AND C2 <>''
AND C6 IN ('V6') AND C4='25' AND C5 IN ('1238','1296',...)
AND C7 IN ('v7a')
UNION ALL
-- Branch 2: c4='4' AND C5 IN(...)
SELECT C2 FROM t1
WHERE C2 IS NOT NULL AND C2 <>''
AND C4 ='4' AND 5 IN ('10135269','10144642')
UNION ALL
-- Branch 3: c4='20' AND C5 IN(...)
SELECT C2 FROM t1
WHERE C2 IS NOT NULL AND c2 <>''
AND C4 ='20' AND C5 IN ('2000000085', '2000000086',...)
UNION ALL
-- Branches 4-7: NOT IN branches, split in the same way.
SELECT C2 FROM t1
WHERE C2 IS NOT NULL AND c2 <>''
AND C4 ='25' AND C5 NOT IN ('1238','1296',...)
UNION ALL
-- ...other NOT IN branches...
) AS sub;


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback