Repository navigation
Description
Is there an existing issue for the same bug?
I searched open and closed MatrixOne issues and PRs for the exact tuple-decode error, serial_extract, single-column unique indexes, extra filters, and FORCE INDEX.
This is distinct from:
- [Bug]: pessimistic mode:pipeline hung #10882: an old pessimistic-pipeline hang that only happens to contain the same low-level error text in logs.
- [Bug]: select return result is incorrect which where filter condition is unique index #19108: an older wrong-result report for
INon a unique key, without an extra same-column predicate or tuple decoding. - [Bug]: Index-only aggregates over composite secondary indexes return zero or NULL #25348 / [Bug]: covering ORDER BY and DISTINCT queries over composite secondary indexes return empty results #25396: composite secondary-index covering scans; their keys are serialized tuples.
- [Bug]: Prefix-index covering queries drop values longer than the indexed prefix #26813: explicitly declared prefix indexes losing full values in covering reads. This reproduction uses an ordinary, non-prefix unique index.
Branch Name
main
Commit ID
08770e1beeb23239c91165492f2fe85243a3c66a
Other Environment Information
- Local single-node MatrixOne on Linux
- Built from the commit above with Go 1.26.4
- MySQL client against port 6001
- Reproduces before and after an explicit TN flush
Actual Behavior
An equality lookup through an ordinary single-column unique secondary index succeeds by itself, but adding another valid predicate on the same indexed column makes the query fail with an internal tuple-decoding error.
The failure also occurs without FORCE INDEX because the optimizer chooses the unique index naturally.
ERROR 20101 (HY000): internal error: unable to decode tuple element with unknown typecode 61
IGNORE INDEX returns the expected row. An extra predicate on a non-indexed payload also succeeds, which isolates the bug to pushing a second predicate on the indexed column.
Expected Behavior
Adding a redundant or narrowing predicate must not turn a valid unique-index lookup into an internal error. The indexed and base-table paths should both return row (1, 'abcdx', 'p1').
Steps to Reproduce
DROP DATABASE IF EXISTS unique_index_extra_filter_repro;
CREATE DATABASE unique_index_extra_filter_repro;
USE unique_index_extra_filter_repro;
CREATE TABLE t (
id INT PRIMARY KEY,
a VARCHAR(32),
payload VARCHAR(32),
UNIQUE INDEX uq_a(a)
);
INSERT INTO t VALUES
(1, 'abcdx', 'p1'),
(2, 'abce0', 'p2');
-- Control: the point lookup succeeds.
SELECT id, a, payload
FROM t FORCE INDEX(uq_a)
WHERE a = 'abcdx';
-- 1, abcdx, p1
-- Wrong: an additional predicate on the unique-key column crashes.
SELECT id, a, payload
FROM t FORCE INDEX(uq_a)
WHERE a = 'abcdx' AND a LIKE 'abcdx%';
-- ERROR 20101 ... unable to decode tuple element with unknown typecode 61
SELECT id, a, payload
FROM t FORCE INDEX(uq_a)
WHERE a = 'abcdx' AND a > 'abcdw';
-- same internal error
-- Correct base-table control.
SELECT id, a, payload
FROM t IGNORE INDEX(uq_a)
WHERE a = 'abcdx' AND a LIKE 'abcdx%';
-- 1, abcdx, p1
-- A predicate on a non-indexed column also succeeds.
SELECT id, a, payload
FROM t FORCE INDEX(uq_a)
WHERE a = 'abcdx' AND payload = 'p1';
-- 1, abcdx, p1
SELECT mo_ctl('dn', 'flush', 'unique_index_extra_filter_repro.t');
-- Repeat the failing and control queries: behavior is unchanged.Additional Information
EXPLAIN VERBOSE exposes the invalid filter on the hidden unique-index table:
Index Table Scan on t.uq_a
Filter Cond:
(__mo_index_idx_col = 'abcdx'),
prefix_eq(serial_extract(__mo_index_idx_col, 0, VARCHAR))
A one-part unique index stores __mo_index_idx_col directly in the indexed column's type. It is not a serial_full tuple. However, applyExtraFiltersOnIndex rewrites every extra predicate on an indexed part through MakeSerialExtractExpr, so execution interprets the raw VARCHAR bytes as tuple-encoded data.
The safe mapping is shape-dependent:
- direct one-part unique key: use
__mo_index_idx_coldirectly; - serialized composite/non-unique key: use
serial_extract; - lossy prefix part: do not push a full-value predicate to the hidden index; retain the base-table residual.
Please retain black-box coverage for default / FORCE / IGNORE paths, same-column versus payload predicates, in-memory and post-flush reads, plus a planner assertion that a direct one-part key never receives serial_extract.
Activity
LeftHandCold commentedon Aug 9, 2026
Fixed locally in commit 02c916393dbaf305913dd8a5100e2f6dffc415ef.
The fix makes extra-filter pushdown follow the hidden key's physical representation:
Validated on a locally built MO service:
fix(plan): preserve direct unique index extra filters (matrixorigin#2…
fix(plan): preserve direct unique index extra filters (matrixorigin#2…
fix: harden regular prefix index correctness (#26829)
LeftHandCold commentedon Aug 11, 2026
Validation result — fixed by #26829.
Verified on the exact merge commit
ac339444b558daf2c3d7fe63f755743449db7696, with an08770e1baseline comparison.Baseline: FORCE INDEX on a one-column unique key plus a second predicate on that same column failed with
ERROR 20101 ... unknown typecode 61.Fix verification: LIKE, forward/reverse range, and non-indexed payload residual predicates all return the expected row through FORCE and IGNORE, before and after TN flush. The planner now keeps a one-part unique raw key as a raw value;
serial_extractremains limited to serialized composite-key shapes.Focused and complete
pkg/catalog+pkg/sql/plantests and the PR BVT case passed.Conclusion: the reported planner/execution defect is fixed. Closing.
fix: harden regular prefix index correctness (matrixorigin#26829)
fix: harden regular prefix index correctness (matrixorigin#26829)
fix: harden regular prefix index correctness (matrixorigin#26829)