Repository navigation
Description
Summary and evidence boundary
The CN logtailreplay.Exact primary-key iterator stops after inspecting three historical candidates, even when every inspected candidate is a transferred deletion of an older physical row. It can return no row before examining a fourth candidate that is a valid visible INSERT.
This issue tracks a read-path correctness gap demonstrated with controlled TAE Flush scheduling and real in-process SQL. The affected iterator, validation, ordering and PK call path remain in current main. The SQL red/green was run on the 4.2 incident source below, not on the latest main binary. Automatic scheduler reachability under ordinary service configuration has not been demonstrated. It is not a claim that issue #32515's production root cause has been identified.
Versions
- Latest main inspected on 2026-11-13:
a626dd045a656c801b6730732adc16df056379d3. - Source used for executed SQL A/B:
a7bc2008e9236708fee0328376f2c2c6b6f0d3fc(4.2). - Linux, local host 50,
GOMAXPROCS=2, package build parallelism 1; in-process TAE + Disttae + InternalSQLExecutor, not an external service cluster. - Both A/B runs used the identical test and read-only BuildReaders observer. The only behavioral A/B difference was removing
Exact's candidate budget. The production checkout was not patched; Go overlays supplied the diagnostic changes.
Actual and expected behavior
For one composite primary key, the relevant ordered prefix can be:
same key K, candidates at/before read snapshot S, newest first
D(old row 2, transferred delete)
D(old row 1, transferred delete)
D(old row 0, transferred delete)
I(current live row, offset=3, step=1)
These deletes target different, older physical rows. They do not mean the current live row was deleted. Exact.Move skips them but still consumes the candidate budget; the fourth item is never checked. This is a silent zero-row result, not a query error.
Expected: an exact PK lookup must agree with a full scan on whether that key has a valid row in the same read state and snapshot. A fixed count of historical candidates is not, by itself, proof of absence.
At the final phase of the controlled SQL reproduction:
| Query | Original Exact | Budget removed (diagnostic only) |
|---|---|---|
Full composite PK, FOR UPDATE |
0 rows, no error | 1 row: (3,1) |
| Full composite PK, ordinary SELECT | 0 rows, no error | 1 row: (3,1) |
| PK prefix SELECT | 1 row: (3,1) |
1 row: (3,1) |
| Full scan | 1 row: (3,1) |
1 row: (3,1) |
Within each phase/run, the four queries shared a fixed SI transaction snapshot and the actual Reader state was inspected. A/B runs built independent states; they did not share physical state or timestamps across runs. The same 16-query oracle fails two assertions on baseline and passes all 16 with the diagnostic budget removal. Baseline exits 1; diagnostic exits 0. This is a correctness differential, not a performance measurement.
Code responsible and current-main check
- Exact budget and skipped-delete accounting.
- Candidate validity and Next.
- EQUAL selects Exact.
- Filtered PK iterator entry.
- PrimaryIndexEntry order: key, descending Time, descending RowEntryID.
These functions and ordering were compared against the executed a7 source and are unchanged. The cnt := 3 / cnt <= 0 exit remains. Thus the same admitted candidate prefix still causes the reader algorithm to miss the fourth item. Other parts of main have changed, including RowEntry COW, Flush/tombstone handling and other index paths; source equivalence of the iterator is not an end-to-end main reproduction of the history producer.
How the controlled history was produced
The test creates an actual compound-key catalog definition equivalent to:
CREATE TABLE offsets (
table_id BIGINT UNSIGNED NOT NULL,
col_name VARCHAR(64) NOT NULL,
offset BIGINT UNSIGNED NOT NULL,
step BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (table_id, col_name)
);Schema creation uses the real engine/catalog APIs. INSERT, UPDATE and SELECT use the internal SQL executor. The fixture sets BlockMaxRows=1 and ObjectMaxBlocks=1 so each successive version occupies a separate appendable object.
- Insert
(399944,'a',0,1)and commit. - Start F0 on the object holding the current row, call the actual Flush task
OnExec, and hold its transaction uncommitted. UPDATE offset to 1 through SQL and commit. - Similarly start F1 on the next object and UPDATE to 2; start F2 on the third object and UPDATE to 3. Each SQL UPDATE affects one row and commits successfully.
- Commit F0, F1 and F2 in order, allowing real Flush transfer-delete generation and logtail publication; inspect after each commit.
- At each of four phases (before Flush commits and after each one), run all four SELECT forms above. After F2 the live insertion falls beyond Exact's budget.
The harness does not fabricate PrimaryIndexEntry records, omit the current INSERT from logtail, or modify transfer-delete semantics to obtain the result. However it does directly drive the tasks and defer their commits, bypassing normal flusher admission and worker sequencing. It passes no source tombstone objects to these task constructors. The repository's normal flusher also chooses/freeze-checks tombstone inputs, which this fixture does not reproduce. The registered transaction mode is Pessimistic, but lockservice, logtail RPC transport and cluster topology are test adapters; isolation is explicitly SI. This does not validate distributed locks, RC retry behavior, or normal scheduling frequency.
Additional observation preserved from the raw output: the auxiliary TN full scan reports one row, while auxiliary GetValueByFilter reports not found after each Flush in both A/B versions, already after F0. That observation is unexplained here and is not evidence that TN point lookup is healthy. It is distinct from the third-Flush CN Exact-only differential; the proof here is the CN same-state exact/prefix/full comparison.
Scope and relationship to other issues
- [Bug]: incrservice: 4.2 AP CN exits on zero-row allocator reads during concurrent primary-key UPDATE #32515 is an allocator FATAL incident. Its known pre-failure history does not establish these three pending Flushes or a fourth live candidate. Fixing this component issue alone would not prove that incident resolved.
- [Bug]: 4.2 CN logtail replay mutates RowEntry objects shared with published snapshots #32613 / [4.2-dev] fix(disttae): preserve RowEntry snapshot isolation during replay #32616 track RowEntry copy-on-write ownership; they are separate from the fixed candidate count. Main already contains the relevant COW change but retains this Exact budget.
- [Bug]: data branch snapshot scan can miss catalog rows during flush #25686 and [Bug]: disttae can admit a stale PartitionState after pending logtail clears #26006 concern state capture/admission across snapshots. Here the exact/prefix/full comparison uses the same captured Reader state; this is a different failure mechanism.
- No ordinary client-only SQL script or probability of occurrence in production is claimed. No durable data loss, allocator duplicate IDs, or latest-main service failure has been established by this test.
Fix and acceptance requirements
Removing the cap was used to isolate the cause, not submitted as a ready-to-merge fix. The fix must retain snapshot/delete semantics and be evaluated for long-history cost, absence lookups, retained memory and cancellation. Increasing the cap to another constant would not establish correctness.
Acceptance should include a deterministic same-state iterator regression on main, a controlled SQL differential with both ordinary and FOR UPDATE complete-PK queries, and an explicit audit or test of history reachability through normal scheduling. Prefix/full reads, deleted keys, historical snapshots and valid earlier/later versions must remain correct. Keep production reachability and #32515 attribution separate until demonstrated.
The complete executed harness and the two small diagnostic diffs are included below so reviewers can audit or reproduce the controlled result. Native dependencies must be built for the stated source version; no external incident data is needed.
Complete controlled reproduction, native test wrapper, and diagnostic diffs
Controlled reader-contract reproducer: complete source and boundaries
This is a deterministic in-process reader correctness reproducer, not a standalone SQL script, a normal automatic-flusher execution, an RC retry reproduction, or proof of the original #32515 incident cause. No production/main cluster was started by this fixture.
Tested source/runtime and unchanged A/B oracle
- Actual source used for both runs:
a7bc2008e9236708fee0328376f2c2c6b6f0d3fc(observed incident branch4.2-dev). The incident image wassha256:56a64cbbb7a86ada87c4e1af656791be329714ef0fe60e3ecae1aa8955432ee8; this fixture compiled repository test code and did not run that service image. - Linux in-process TAE + Disttae + the real SQLExecutor, local filesystem,
GOMAXPROCS=2, build-p 1; repositorygo.modrequires Go1.26.4. The old receipts did not separately savego version, so this appendix does not infer an exact compiler patch version from today's PATH. - Reused native
cgo/libmo.soSHA256:898ff8b59554b09388fc4a7f76b73b19242e3cc4694cd888d4ff3034e3b7078e. No native rebuild was performed for these two historical runs or this appendix review. - Real fixture transactions log Pessimistic / SI, not RC. Each phase creates one SI transaction, runs all four SELECTs under that same fixed snapshot, verifies its actual BuildReaders State, then rolls it back. There are four phases/16 queries, not one transaction spanning all phases.
- Logtail messages originate from real TAE commits and push-logtail publication. The RPC transport is
NewMockLogtailAgent(in-process channels); CN/TN transaction transport uses the test sender; topology/HAKeeper and lockservice are test doubles.mockLockService.Lockreturns an empty successful result andIsOrphanTxnreturns false. ConsequentlyFOR UPDATEexercises the SQL/reader path, not a production distributed lock conflict. - The latest inspected main SHA
a626dd045a656c801b6730732adc16df056379d3has the same Exact-function SHA2563d077a12292098fc19b9e2c7c22c83fb79c73aada103dc4c46a10e846afeddce. This is fixed-SHA source comparison only; these A/B runs were a7, not main runtime validation.
The logical DDL equivalent is below. The actual fixture builds the schema with TAE APIs, including hidden __mo_cpkey_col, rather than executing this CREATE TABLE SQL. It is an ordinary four-visible-column test table, not the actual mo_increment_columns catalog schema or an Allocate integration test.
CREATE DATABASE transfer_sql;
CREATE TABLE transfer_sql.offsets (
table_id BIGINT UNSIGNED NOT NULL,
col_name VARCHAR(64) NOT NULL,
offset BIGINT UNSIGNED NOT NULL,
step BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (table_id, col_name)
);
INSERT INTO transfer_sql.offsets VALUES(399944,'a',0,1);Physical fixture settings are BlockMaxRows=1, ObjectMaxBlocks=1. For each i=0..2 the test starts a real TN transaction Fi, locates the current source object, closes its handle, requires PrepareCompact(), calls NewFlushTableTailTask(nil, Fi, [source], nil, runtime).OnExec(ctx), and deliberately does not commit Fi yet. It then executes and commits the ordinary SQL UPDATE setting offset to i+1. The three source objects are required to differ. The controlled order is:
SQL INSERT v0; commit
F0 OnExec; hold Active -> SQL UPDATE offset=1; commit
F1 OnExec; hold Active -> SQL UPDATE offset=2; commit
F2 OnExec; hold Active -> SQL UPDATE offset=3; commit
four queries before_flush
commit F0; real LogtailMgr.ReadBarrier; four queries flush0
commit F1; real LogtailMgr.ReadBarrier; four queries flush1
commit F2; real LogtailMgr.ReadBarrier; four queries flush2
No RowID, commit timestamp or delete-logtail row is hand-injected. However the fixture bypasses automatic discovery/scheduling and passes nil tombstone-object inputs to each task. Normal flusher admission also gathers/freezes current appendable tombstones. It must not be described as a natural automatic-flusher reproduction.
The three actual UPDATE statements are:
UPDATE transfer_sql.offsets SET offset=1 WHERE table_id=399944 AND col_name='a';
UPDATE transfer_sql.offsets SET offset=2 WHERE table_id=399944 AND col_name='a';
UPDATE transfer_sql.offsets SET offset=3 WHERE table_id=399944 AND col_name='a';Each returned AffectedRows=1 and committed without error. Each phase then executes these exact queries, in order:
SELECT offset,step FROM transfer_sql.offsets WHERE table_id=399944 AND col_name='a' FOR UPDATE;
SELECT offset,step FROM transfer_sql.offsets WHERE table_id=399944 AND col_name='a';
SELECT offset,step FROM transfer_sql.offsets WHERE table_id=399944;
SELECT offset,step FROM transfer_sql.offsets;Every query is required to return exactly [[3,1]] with no SQL error. Failures are collected until all16 queries and reader observations have been emitted; both variants use the identical test/expectations.
| # | Phase | Query | a7 baseline rows | diagnostic-only unlimited rows |
|---|---|---|---|---|
| 1 | before_flush | for_update | [[3,1]] |
[[3,1]] |
| 2 | before_flush | exact | [[3,1]] |
[[3,1]] |
| 3 | before_flush | prefix | [[3,1]] |
[[3,1]] |
| 4 | before_flush | full | [[3,1]] |
[[3,1]] |
| 5 | flush0 | for_update | [[3,1]] |
[[3,1]] |
| 6 | flush0 | exact | [[3,1]] |
[[3,1]] |
| 7 | flush0 | prefix | [[3,1]] |
[[3,1]] |
| 8 | flush0 | full | [[3,1]] |
[[3,1]] |
| 9 | flush1 | for_update | [[3,1]] |
[[3,1]] |
| 10 | flush1 | exact | [[3,1]] |
[[3,1]] |
| 11 | flush1 | prefix | [[3,1]] |
[[3,1]] |
| 12 | flush1 | full | [[3,1]] |
[[3,1]] |
| 13 | flush2 | for_update | [] |
[[3,1]] |
| 14 | flush2 | exact | [] |
[[3,1]] |
| 15 | flush2 | prefix | [[3,1]] |
[[3,1]] |
| 16 | flush2 | full | [[3,1]] |
[[3,1]] |
All32 recorded SQL errors are empty. Actual reader-state observations show0/1/2/3 strictly-newer transfer deletes in the four phases, with the same State/snapshot for the four queries of each phase. At three deletes the baseline raw Exact/Prefix/Full counts are0/1/1, while the diagnostic variant returns1/1/1. The third skipped candidate exhausts Exact's fixed cnt=3 before the visible insert is inspected.
Historical red receipt: exit1, outer7.026s, test0.62s; only flush2/for_update and flush2/exact violate the oracle. Historical green receipt: exit0, outer33.533s, test0.63s, all16 correct. The observer overlay is identical in both; the only additional behavioral delta in green removes the Exact candidate budget. The removal is causal diagnosis, not a proposed production fix. The historical command included -vet=off; this is retained faithfully and is not a claim of vet validation. The earlier compile failure is separately archived and is not counted as either result.
Scheduler and TN-helper limits
The a7 scheduler does not contain an unconditional table-wide single-flight guard: db/dispatcher.go:25 allows distinct nonempty segment/object scopes within one table; checkpoint/flusher.go:747-787 supplies object scopes. Table compact stats contain a randomized flush deadline/last merge time, not a pending-flush mutex. This does not establish this history under normal scheduling. Admission includes dirty-tree visibility, deadlines/pressure, PrepareCompact, the shared tombstone set, worker count, and Preparing/commit waits. ScheduledTxnTask.Execute calls OnExec then immediately Commit. In this fixture's GOMAXPROCS=2 default configuration there is one flush worker; the fixture bypasses it and manually holds three Active transactions. Automatic three-pending reachability has not been executed or proved. All controlled SQL and Flush commits returned nil; no mandatory commit rejection was observed, but this is not proof of all scheduler/production invariants.
Also retain the separate TN observation: after each of the three Flush commits, both variants report TN GetValueByFilter(...)=not found, while independent TN HybridScan reports one row. This is a real helper path (txnRelation.GetValueByFilter -> txnTable.GetByFilter), not a demonstrated unsupported mock operation. Its cause is unexplained here, it starts at the first Flush and is unchanged by the Exact delta. The fixture does not assert that TN point lookup succeeds; do not present it as TN point-read confirmation or silently discard this observation. It does not, by itself, prove that the commits were rejected or explain the third-stage Exact-only A/B difference.
Save files and run
Minimal source attachments are the three complete fences below. Normalized a/b diff headers reconstruct exactly the archived full overlay files from clean a7:
| Saved filename | Bytes | SHA256 |
|---|---|---|
compound_sql_test.go |
17990 | 8096be5ca4bcc023cc97cbb392122add140c81deec88a809c5a86bfff3d0592f |
reader-observer-only.diff (normalized header) |
495 | 78ba1fd256b6ccc5f233789540f7f53c280c6166b7ba70b7fd6d2968b2d3a12c |
exact-budget-only.diff (normalized header) |
653 | 98de42e57fd3d1cd668fff746249ded45e29fdd3a5419b22edfc739cca83ead7 |
Generated observer full-file SHA256 is 7bbb84cc9780b0991cbcdd0448ecd729d19b6abe8941f21319202aeb3a2d6f40; generated unlimited rows_iter SHA256 is 654443fd47652933cc0dc57e711ffb7643f11050ea293bc5c28cecb4c0a675c0. The baseline original rows_iter SHA256 was 7ab1878059ee6098297db473ab0b0e80259a58727f37e7b473755932e2c4ecbe.
The path-parameterized setup/overlay recipe below is packaging documentation, not a newly executed run. The historical native-ready runner used the same two test invocations, a180s outer guard, >=6GiB disk floor, and the receipts listed below. First build this revision's own native/thirdparty prerequisites by repository instructions (e.g. its make cgo target); the wrapper refuses missing cgo/libmo.so or thirdparties/install/include. A cold build can cost substantially more than the recorded warm/native-ready test times.
# Use a fresh checkout/worktree at the tested SHA. Do not use a later modified worktree.
MO_REPRO_SOURCE=/absolute/path/matrixone-a7
MO_REPRO_ARTIFACTS=/absolute/path/exact-transfer-repro
# In that checkout: build its own native prerequisites by the repository instructions.
# `make cgo` depends on `thirdparties`; this preparation was NOT rerun for this appendix.
# Save the three fenced attachments below in MO_REPRO_ARTIFACTS using the stated filenames.
mkdir -p "$MO_REPRO_ARTIFACTS/tmp" "$MO_REPRO_ARTIFACTS/sql-baseline/result" "$MO_REPRO_ARTIFACTS/sql-unlimited/result"
cp "$MO_REPRO_SOURCE/pkg/vm/engine/disttae/txn_table.go" "$MO_REPRO_ARTIFACTS/txn_table_reader_observer.go"
cp "$MO_REPRO_SOURCE/pkg/vm/engine/disttae/logtailreplay/rows_iter.go" "$MO_REPRO_ARTIFACTS/rows_iter_unlimited.go"
patch --batch "$MO_REPRO_ARTIFACTS/txn_table_reader_observer.go" "$MO_REPRO_ARTIFACTS/reader-observer-only.diff"
patch --batch "$MO_REPRO_ARTIFACTS/rows_iter_unlimited.go" "$MO_REPRO_ARTIFACTS/exact-budget-only.diff"
python3 - "$MO_REPRO_SOURCE" "$MO_REPRO_ARTIFACTS" <<'PYOVERLAY'
from pathlib import Path
import json,sys
source,artifacts=map(Path,sys.argv[1:])
common={str(source/'pkg/vm/engine/disttae/txn_table.go'):str(artifacts/'txn_table_reader_observer.go')}
(artifacts/'sql-baseline/overlay.json').write_text(json.dumps({'Replace':common},indent=2)+'\n')
green=dict(common)
green[str(source/'pkg/vm/engine/disttae/logtailreplay/rows_iter.go')]=str(artifacts/'rows_iter_unlimited.go')
(artifacts/'sql-unlimited/overlay.json').write_text(json.dumps({'Replace':green},indent=2)+'\n')
PYOVERLAY
# Invoke separately: baseline returns 1; unlimited returns 0. Preserve each actual exit.
cd "$MO_REPRO_SOURCE"
GOMAXPROCS=2 TMPDIR="$MO_REPRO_ARTIFACTS/tmp" GOTMPDIR="$MO_REPRO_ARTIFACTS/tmp" ISSUE32515_SQL_OUT="$MO_REPRO_ARTIFACTS/sql-baseline/result" \
"$MO_REPRO_SOURCE/.agents/skills/mo-dev/scripts/mo-cgo-test" -p 1 -vet=off \
-overlay="$MO_REPRO_ARTIFACTS/sql-baseline/overlay.json" -v -count=1 -timeout=150s \
'-run=^TestCompoundSQLThreePendingFlushes$' "$MO_REPRO_ARTIFACTS/compound_sql_test.go"
GOMAXPROCS=2 TMPDIR="$MO_REPRO_ARTIFACTS/tmp" GOTMPDIR="$MO_REPRO_ARTIFACTS/tmp" ISSUE32515_SQL_OUT="$MO_REPRO_ARTIFACTS/sql-unlimited/result" \
"$MO_REPRO_SOURCE/.agents/skills/mo-dev/scripts/mo-cgo-test" -p 1 -vet=off \
-overlay="$MO_REPRO_ARTIFACTS/sql-unlimited/overlay.json" -v -count=1 -timeout=150s \
'-run=^TestCompoundSQLThreePendingFlushes$' "$MO_REPRO_ARTIFACTS/compound_sql_test.go"For exact historical argv (unmodified paths), the preserved receipts contain:
{
"baseline": [
"/home/mo/incr32515-errorpath-20261112.RMolpIPJ/src/.agents/skills/mo-dev/scripts/mo-cgo-test",
"-p",
"1",
"-vet=off",
"-overlay=/home/mo/code/matrixone-investigations/issue32515-rootcause-20261112/transfer-probe/sql-baseline/overlay.json",
"-v",
"-count=1",
"-timeout=150s",
"-run=^TestCompoundSQLThreePendingFlushes$",
"/home/mo/code/matrixone-investigations/issue32515-rootcause-20261112/transfer-probe/compound_sql_test.go"
],
"unlimited": [
"/home/mo/incr32515-errorpath-20261112.RMolpIPJ/src/.agents/skills/mo-dev/scripts/mo-cgo-test",
"-p",
"1",
"-vet=off",
"-overlay=/home/mo/code/matrixone-investigations/issue32515-rootcause-20261112/transfer-probe/sql-unlimited/overlay.json",
"-v",
"-count=1",
"-timeout=150s",
"-run=^TestCompoundSQLThreePendingFlushes$",
"/home/mo/code/matrixone-investigations/issue32515-rootcause-20261112/transfer-probe/compound_sql_test.go"
]
}The wrapper is tracked at a7, and its preserved local file is byte-identical (3875bytes, SHA256 1089e24e8462d2585263f274b64dc23443bbcb4df78d1e2db3d4e643932ff63a). Its full content follows for completeness; save it only at the versioned path inside the checkout so its git-root lookup resolves the intended source.
Versioned .agents/skills/mo-dev/scripts/mo-cgo-test
#!/bin/sh
# Copyright 2021 - 2026 Matrix Origin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eu
usage() {
echo "usage: $0 [go test flags and package patterns...]" >&2
echo "example: $0 -race -count=1 -timeout=120s ./pkg/target/..." >&2
}
if [ "$#" -eq 0 ]; then
usage
exit 2
fi
script_dir=$(CDPATH= cd -P "$(dirname "$0")" && pwd)
repo_root=$(git -C "$script_dir" rev-parse --show-toplevel)
case "$repo_root" in
*[[:space:]]*)
echo "MatrixOne's Make/CGo flags require a repository path without whitespace: $repo_root" >&2
exit 1
;;
esac
cgo_dir="$repo_root/cgo"
thirdparty_dir="$repo_root/thirdparties/install"
lib_dir="$thirdparty_dir/lib"
include_dir="$thirdparty_dir/include"
goos=$(go env GOOS)
gohostos=$(go env GOHOSTOS)
goarch=$(go env GOARCH)
gohostarch=$(go env GOHOSTARCH)
if [ "$goos" != "$gohostos" ] || [ "$goarch" != "$gohostarch" ]; then
echo "local MatrixOne CGo tests do not support cross compilation:" \
"target=$goos/$goarch, host=$gohostos/$gohostarch" >&2
exit 1
fi
if [ "$(go env CGO_ENABLED)" != "1" ]; then
echo "MatrixOne CGo tests require CGO_ENABLED=1" >&2
exit 1
fi
case "$goos" in
darwin)
libmo="$cgo_dir/libmo.dylib"
runtime_path_var=DYLD_LIBRARY_PATH
platform_link_flags=
;;
linux)
libmo="$cgo_dir/libmo.so"
runtime_path_var=LD_LIBRARY_PATH
platform_link_flags=-fopenmp
;;
*)
echo "unsupported GOOS for MatrixOne CGo tests: $goos" >&2
exit 1
;;
esac
for required in "$libmo" "$include_dir"; do
if [ ! -e "$required" ]; then
echo "missing MatrixOne CGo prerequisite: $required" >&2
echo "build the repository thirdparties and CGo libraries before testing" >&2
exit 1
fi
done
# Match the repository build contract and remove ambient module/CGo flag
# drift. CC/CXX and other standard toolchain selectors remain caller-owned.
export GOWORK=off
export CGO_CFLAGS="'-I$cgo_dir' '-I$include_dir'"
export CGO_LDFLAGS="'-L$lib_dir'"
# cgo/lib.go owns libmo's native dependency declaration. Query that metadata
# instead of duplicating a library list here; newly added CPU dependencies then
# flow into this wrapper automatically. The repository-path check above makes
# the space-delimited result safe to append to extldflags.
cgo_link_flags=$(go -C "$repo_root" list -mod=readonly \
-f '{{join .CgoLDFLAGS " "}}' ./cgo)
if [ -z "$cgo_link_flags" ]; then
echo "MatrixOne's cgo package declared no native link flags" >&2
exit 1
fi
runtime_paths="$cgo_dir:$lib_dir"
if [ "$runtime_path_var" = DYLD_LIBRARY_PATH ]; then
export DYLD_LIBRARY_PATH="$runtime_paths"
else
export LD_LIBRARY_PATH="$runtime_paths"
fi
# go test executables run from temporary build directories. Use repository
# absolute rpaths; package-relative rpaths belong to distributable binaries.
#
# The wrapper injects libmo even when the requested package does not import
# cgo/lib.go, so it must also close libmo's dependency graph. Keep the queried
# flags after -lmo: archive resolution is order-sensitive on common linkers.
external_flags="$platform_link_flags -L$cgo_dir -lmo $cgo_link_flags -Wl,-rpath,$cgo_dir -Wl,-rpath,$lib_dir"
ldflags="-extldflags '$external_flags'"
cd "$repo_root"
exec go test -mod=readonly -ldflags "$ldflags" "$@"Attachment1: compound_sql_test.go (complete)
package transferprobe
import (
"bytes"
"context"
"encoding/hex"
"encoding/json"
"fmt"
"os"
"path/filepath"
"sort"
"sync"
"testing"
"time"
"github.com/matrixorigin/matrixone/pkg/catalog"
"github.com/matrixorigin/matrixone/pkg/common/mpool"
moruntime "github.com/matrixorigin/matrixone/pkg/common/runtime"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/defines"
"github.com/matrixorigin/matrixone/pkg/fileservice"
pbplan "github.com/matrixorigin/matrixone/pkg/pb/plan"
pbtxn "github.com/matrixorigin/matrixone/pkg/pb/txn"
"github.com/matrixorigin/matrixone/pkg/sql/plan/function"
"github.com/matrixorigin/matrixone/pkg/txn/client"
"github.com/matrixorigin/matrixone/pkg/util/executor"
"github.com/matrixorigin/matrixone/pkg/vm/engine"
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/logtailreplay"
"github.com/matrixorigin/matrixone/pkg/vm/engine/readutil"
taecatalog "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/catalog"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/containers"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/handle"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/txnif"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/tables/jobs"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/testutils/config"
"github.com/matrixorigin/matrixone/pkg/vm/engine/test/testutil"
"github.com/stretchr/testify/require"
)
func stateFromActualReaderRanges(r engine.RelData) *logtailreplay.PartitionState {
switch v := r.(type) {
case *readutil.ObjListRelData:
state, _ := v.PState.(*logtailreplay.PartitionState)
return state
case *readutil.BlockListRelData:
state, _ := v.GetPState().(*logtailreplay.PartitionState)
return state
default:
return nil
}
}
// Both A/B variants use this identical correctness oracle: every query must
// return offset=3, step=1. The baseline is expected to fail after collecting
// every query result and actual reader state; the diagnostic overlay should pass.
func TestCompoundSQLThreePendingFlushes(t *testing.T) {
out := os.Getenv("ISSUE32515_SQL_OUT")
require.True(t, filepath.IsAbs(out))
require.NoError(t, os.MkdirAll(out, 0755))
file, err := os.Create(filepath.Join(out, "events.jsonl"))
require.NoError(t, err)
defer func() { require.NoError(t, file.Close()) }()
emit := func(event map[string]any) {
t.Helper()
encoded, err := json.Marshal(event)
require.NoError(t, err)
_, err = fmt.Fprintln(file, string(encoded))
require.NoError(t, err)
t.Log(string(encoded))
}
ctx, cancel := context.WithTimeout(context.WithValue(context.Background(), defines.TenantIDKey{}, uint32(0)), 150*time.Second)
t.Cleanup(cancel)
data := t.TempDir()
fs, err := fileservice.NewLocalFS(ctx, defines.SharedFileServiceName, filepath.Join(data, "shared"), fileservice.CacheConfig{}, nil)
require.NoError(t, err)
t.Cleanup(func() { fs.Close(context.Background()) })
rpc := testutil.NewMockLogtailAgent()
t.Cleanup(rpc.Close)
opts := config.WithLongScanAndCKPOpts(nil)
opts.Fs = fs
tn, err := testutil.NewTestTAEEngine(ctx, filepath.Join(data, "tae"), t, rpc, opts)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tn.Close(true)) })
mp := mpool.MustNewZero()
t.Cleanup(func() { mpool.DeleteMPool(mp) })
cn, err := testutil.NewTestDisttaeEngine(ctx, fs, rpc, tn, testutil.WithDisttaeEngineMPool(mp))
require.NoError(t, err)
t.Cleanup(func() { cn.Close(context.Background()) })
v, ok := moruntime.ServiceRuntime("").GetGlobalVariables(moruntime.InternalSQLExecutor)
require.True(t, ok)
sql := v.(executor.SQLExecutor)
newTxn := func() (client.TxnOperator, *bool) {
t.Helper()
op, err := cn.NewTxnOperator(ctx, cn.Now(), client.WithTxnIsolation(pbtxn.TxnIsolation_SI))
require.NoError(t, err)
done := new(bool)
t.Cleanup(func() {
if !*done {
cleanup, stop := context.WithTimeout(context.Background(), 5*time.Second)
defer stop()
require.NoError(t, op.Rollback(cleanup))
}
})
return op, done
}
trackTN := func(txn txnif.AsyncTxn) *bool {
done := new(bool)
t.Cleanup(func() {
if !*done {
require.NoError(t, txn.Rollback(context.Background()))
}
})
return done
}
execOne := func(op client.TxnOperator, statement string) (executor.Result, error) {
var result executor.Result
err := sql.ExecTxn(ctx, func(tx executor.TxnExecutor) error {
var err error
result, err = tx.Exec(statement, executor.StatementOption{}.WithDisableLog())
return err
}, executor.Options{}.WithTxn(op))
return result, err
}
// Reuse R6's real compound catalog definition; SchemaToDefs carries Extra.
schema := taecatalog.NewEmptySchema("offsets")
for _, col := range []struct {
name string
typ types.Type
}{{"table_id", types.T_uint64.ToType()}, {"col_name", types.New(types.T_varchar, 64, 0)},
{"offset", types.T_uint64.ToType()}, {"step", types.T_uint64.ToType()}} {
require.NoError(t, schema.AppendCol(col.name, col.typ))
schema.ColDefs[len(schema.ColDefs)-1].NullAbility = false
}
require.NoError(t, schema.AppendPKCol(catalog.CPrimaryKeyColName, types.T_varchar.ToType(), 0))
schema.ColDefs[len(schema.ColDefs)-1].Hidden = true
constraint := &engine.ConstraintDef{Cts: []engine.Constraint{&engine.PrimaryKeyDef{Pkey: &pbplan.PrimaryKeyDef{
Names: []string{"table_id", "col_name"}, PkeyColName: catalog.CPrimaryKeyColName,
CompPkeyCol: &pbplan.ColDef{Name: catalog.CPrimaryKeyColName, Typ: pbplan.Type{Id: int32(types.T_varchar)}, Primary: true, Hidden: true},
}}}}
schema.Constraint, err = constraint.MarshalBinary()
require.NoError(t, err)
schema.Extra.BlockMaxRows, schema.Extra.ObjectMaxBlocks = 1, 1
require.NoError(t, schema.Finalize(false))
create, createDone := newTxn()
require.NoError(t, cn.Engine.Create(ctx, "transfer_sql", create))
db, err := cn.Engine.Database(ctx, "transfer_sql", create)
require.NoError(t, err)
defs, err := taecatalog.SchemaToDefs(schema)
require.NoError(t, err)
require.NoError(t, db.Create(ctx, "offsets", defs))
require.NoError(t, create.Commit(ctx))
*createDone = true
seed, seedDone := newTxn()
seedResult, err := execOne(seed, "insert into transfer_sql.offsets values(399944,'a',0,1)")
seedResult.Close()
require.NoError(t, err)
require.NoError(t, seed.Commit(ctx))
*seedDone = true
inspect, inspectDone := newTxn()
fixtureTxnMeta := inspect.Txn()
cnDB, err := cn.Engine.Database(ctx, "transfer_sql", inspect)
require.NoError(t, err)
cnRel, err := cnDB.Relation(ctx, "offsets", nil)
require.NoError(t, err)
tableID := cnRel.GetTableID(ctx)
require.NoError(t, inspect.Rollback(ctx))
*inspectDone = true
packer := types.NewPacker()
defer packer.Close()
packer.EncodeUint64(399944)
packer.EncodeStringType([]byte("a"))
composite := bytes.Clone(packer.GetBuf())
packer.Reset()
packer.EncodeStringType(composite)
encoded := bytes.Clone(packer.GetBuf())
filter := handle.NewEQFilter(composite)
emit(map[string]any{"event": "fixture", "table_id": tableID, "logical_key": []any{399944, "a"},
"txn_mode": fixtureTxnMeta.Mode.String(), "txn_isolation": fixtureTxnMeta.Isolation.String(),
"pessimistic_txn": fixtureTxnMeta.IsPessimistic(),
"compound_pk_bytes": hex.EncodeToString(composite), "primary_index_bytes": hex.EncodeToString(encoded),
"block_max_rows": 1, "object_max_blocks": 1, "setup": "R6 in-process TAE+Disttae+SQLExecutor",
"mock_boundaries": "logtail RPC channel adapter, lockservice, cluster topology; no standalone service",
"correctness_oracle": "Every FOR UPDATE/exact/prefix/full query must return offset=3, step=1",
"reader_state_source": "actual txnTable.BuildReaders RelData observed by identical A/B diagnostic context overlay"})
type readerObservation struct {
state *logtailreplay.PartitionState
ranges string
filter string
snapshot types.TS
}
var hookMu sync.Mutex
var activeQuery string
var observations []readerObservation
ctx = context.WithValue(ctx, "issue32515.reader-rel-data-observer", func(id uint64, data engine.RelData, expr *pbplan.Expr, snapshot types.TS) {
if id != tableID {
return
}
hookMu.Lock()
defer hookMu.Unlock()
if activeQuery == "" {
return
}
filter := ""
if expr != nil {
filter = expr.String()
}
observations = append(observations, readerObservation{stateFromActualReaderRanges(data), fmt.Sprintf("%T", data), filter, snapshot})
})
var failures []string
countRows := func(iter logtailreplay.RowsIter) int {
t.Helper()
defer func() { require.NoError(t, iter.Close()) }()
n := 0
for iter.Next() {
if bytes.Equal(iter.Entry().PrimaryIndexBytes, encoded) {
n++
}
}
return n
}
queryPhases := func(stage string, newerDeletes int) {
t.Helper()
op, done := newTxn()
fixed := op.SnapshotTS()
err := sql.ExecTxn(ctx, func(tx executor.TxnExecutor) error {
for _, query := range []struct{ name, text string }{
{"for_update", "select offset,step from transfer_sql.offsets where table_id=399944 and col_name='a' for update"},
{"exact", "select offset,step from transfer_sql.offsets where table_id=399944 and col_name='a'"},
{"prefix", "select offset,step from transfer_sql.offsets where table_id=399944"},
{"full", "select offset,step from transfer_sql.offsets"},
} {
hookMu.Lock()
activeQuery, observations = stage+":"+query.name, nil
hookMu.Unlock()
result, queryErr := tx.Exec(query.text, executor.StatementOption{}.WithDisableLog())
hookMu.Lock()
actual := observations
activeQuery, observations = "", nil
hookMu.Unlock()
rows := make([][2]uint64, 0)
for _, bat := range result.Batches {
for i := 0; i < bat.RowCount(); i++ {
rows = append(rows, [2]uint64{vector.GetFixedAtNoTypeCheck[uint64](bat.Vecs[0], i), vector.GetFixedAtNoTypeCheck[uint64](bat.Vecs[1], i)})
}
}
errorText := ""
if queryErr != nil {
errorText = queryErr.Error()
}
if result.LogicalPlan != nil {
planJSON, err := json.MarshalIndent(result.LogicalPlan, "", " ")
require.NoError(t, err)
require.NoError(t, os.WriteFile(filepath.Join(out, stage+"-"+query.name+"-plan.json"), planJSON, 0644))
}
result.Close()
emit(map[string]any{"event": "sql_result", "stage": stage, "query": query.name, "sql": query.text,
"txn_mode": op.Txn().Mode.String(), "txn_isolation": op.Txn().Isolation.String(),
"snapshot_before": types.TimestampToTS(fixed).ToString(), "snapshot_after": types.TimestampToTS(op.SnapshotTS()).ToString(),
"rows": rows, "error": errorText, "actual_reader_observations": len(actual)})
if queryErr != nil || len(rows) != 1 || rows[0] != [2]uint64{3, 1} {
failures = append(failures, fmt.Sprintf("%s/%s: rows=%v error=%s; want [[3 1]]", stage, query.name, rows, errorText))
}
if types.TimestampToTS(op.SnapshotTS()) != types.TimestampToTS(fixed) {
failures = append(failures, stage+"/"+query.name+": fixed SI snapshot changed")
}
if len(actual) == 0 {
failures = append(failures, stage+"/"+query.name+": actual BuildReaders state was not observed")
}
for i, observed := range actual {
if observed.state == nil {
failures = append(failures, stage+"/"+query.name+": actual reader RelData has no PartitionState")
continue
}
state := observed.state
raw := make([]map[string]any, 0)
latestInsert := types.TS{}
iter := state.NewRawReplayRowsIter()
for iter.Next() {
row := iter.Entry()
if !bytes.Equal(row.PrimaryIndexBytes, encoded) {
continue
}
if !row.Deleted && row.Time.GT(&latestInsert) {
latestInsert = row.Time
}
raw = append(raw, map[string]any{"row_id": row.RowID.String(), "time": row.Time.ToString(),
"deleted": row.Deleted, "row_entry_id": row.ID, "primary_index_bytes": hex.EncodeToString(row.PrimaryIndexBytes)})
}
require.NoError(t, iter.Close())
sort.Slice(raw, func(a, b int) bool { return raw[a]["row_entry_id"].(int64) > raw[b]["row_entry_id"].(int64) })
strictNewer := 0
for _, row := range raw {
if row["deleted"].(bool) {
tm := row["time"].(string)
for _, e := range []types.TS{latestInsert} {
var physical int64
var logical uint32
_, err := fmt.Sscanf(tm, "%d-%d", &physical, &logical)
require.NoError(t, err)
deleteTS := types.BuildTS(physical, logical)
if deleteTS.GT(&e) {
strictNewer++
}
}
}
}
exact := countRows(state.NewPrimaryKeyIter(observed.snapshot, function.EQUAL, [][]byte{encoded}))
prefix := countRows(state.NewPrimaryKeyIter(observed.snapshot, function.PREFIX_EQ, [][]byte{encoded}))
full := countRows(state.NewRowsIter(observed.snapshot, nil, false))
emit(map[string]any{"event": "actual_reader_state", "stage": stage, "query": query.name, "ordinal": i,
"state": fmt.Sprintf("%p", state), "ranges_type": observed.ranges, "reader_filter": observed.filter,
"reader_snapshot": observed.snapshot.ToString(), "sql_txn_snapshot": types.TimestampToTS(fixed).ToString(),
"raw_rowid_chain": raw, "latest_insert_time": latestInsert.ToString(),
"strictly_newer_transfer_deletes": strictNewer, "raw_exact_prefix_full": []int{exact, prefix, full}})
if strictNewer != newerDeletes {
failures = append(failures, fmt.Sprintf("%s/%s: newer deletes=%d, want %d", stage, query.name, strictNewer, newerDeletes))
}
}
}
return nil
}, executor.Options{}.WithTxn(op))
require.NoError(t, err)
require.NoError(t, op.Rollback(ctx))
*done = true
}
flushes := make([]txnif.AsyncTxn, 0, 3)
flushDone := make([]*bool, 0, 3)
sources := make(map[string]struct{})
for round := 0; round < 3; round++ {
flush, err := tn.StartTxn()
require.NoError(t, err)
done := trackTN(flush)
database, err := flush.GetDatabase("transfer_sql")
require.NoError(t, err)
relation, err := database.GetRelationByName("offsets")
require.NoError(t, err)
id, offset, err := relation.GetByFilter(ctx, filter)
require.NoError(t, err, "ordinary SQL update must remain a valid source before any flush commit")
obj, err := relation.GetObject(id.ObjectID(), false)
require.NoError(t, err)
meta := obj.GetMeta().(*taecatalog.ObjectEntry)
require.NoError(t, obj.Close())
_, exists := sources[meta.ID().String()]
require.False(t, exists)
sources[meta.ID().String()] = struct{}{}
require.True(t, meta.GetObjectData().PrepareCompact())
task, err := jobs.NewFlushTableTailTask(nil, flush, []*taecatalog.ObjectEntry{meta}, nil, tn.GetDB().Runtime)
require.NoError(t, err)
require.NoError(t, task.OnExec(ctx))
emit(map[string]any{"event": "flush_pending", "round": round, "source_object_id": meta.ID().String(),
"source_row_offset": offset, "destination_object_id": task.GetCreatedObjects().GetMeta().(*taecatalog.ObjectEntry).ID().String(),
"start_ts": flush.GetStartTS().ToString()})
flushes, flushDone = append(flushes, flush), append(flushDone, done)
update, updateDone := newTxn()
statement := fmt.Sprintf("update transfer_sql.offsets set offset=%d where table_id=399944 and col_name='a'", round+1)
result, updateErr := execOne(update, statement)
affected := result.AffectedRows
result.Close()
errorText := ""
if updateErr != nil {
errorText = updateErr.Error()
}
emit(map[string]any{"event": "sql_update", "round": round + 1, "sql": statement, "affected_rows": affected, "error": errorText})
require.NoError(t, updateErr, "do not bypass a real SQL write failure")
require.Equal(t, uint64(1), affected)
commitErr := update.Commit(ctx)
emit(map[string]any{"event": "sql_update_commit", "round": round + 1, "error": fmt.Sprint(commitErr), "txn": update.Txn()})
require.NoError(t, commitErr)
*updateDone = true
}
queryPhases("before_flush", 0)
for round, flush := range flushes {
require.NoError(t, flush.Commit(ctx))
*flushDone[round] = true
frontier, err := tn.GetDB().LogtailMgr.ReadBarrier(ctx)
require.NoError(t, err)
emit(map[string]any{"event": "flush_committed", "round": round, "prepare_ts": flush.GetPrepareTS().ToString(),
"commit_ts": flush.GetCommitTS().ToString(), "published_frontier": frontier})
queryPhases(fmt.Sprintf("flush%d", round), round+1)
check, err := tn.StartTxn()
require.NoError(t, err)
checkDone := trackTN(check)
database, err := check.GetDatabase("transfer_sql")
require.NoError(t, err)
relation, err := database.GetRelationByName("offsets")
require.NoError(t, err)
value, null, lookupErr := relation.GetValueByFilter(ctx, filter, 2)
lookupText := ""
if lookupErr != nil {
lookupText = lookupErr.Error()
}
tnRows := 0
func() {
it := relation.MakeObjectIt(false)
defer func() { require.NoError(t, it.Close()) }()
for it.Next() {
func() {
object := it.GetObject()
defer func() { require.NoError(t, object.Close()) }()
for block := 0; block < object.BlkCnt(); block++ {
func() {
var view *containers.Batch
err := object.HybridScan(ctx, &view, uint16(block), []int{2}, common.DefaultAllocator)
if view != nil {
defer view.Close()
}
require.NoError(t, err)
if view != nil {
view.Compact()
tnRows += view.Length()
}
}()
}
}()
}
}()
emit(map[string]any{"event": "tn_independent_lookup", "round": round,
"pk_lookup_value": value, "pk_lookup_null": null, "pk_lookup_error": lookupText, "full_rows": tnRows})
require.NoError(t, check.Commit(ctx))
*checkDone = true
}
emit(map[string]any{"event": "correctness_oracle", "failures": failures,
"oracle": "same fixed SQL transaction: FOR UPDATE==ordinary exact==prefix==full==[[3,1]]",
"diagnostic_only": true, "production_fix_claimed": false})
require.Empty(t, failures)
}Attachment2: reader-observer-only.diff (complete, normalized paths)
--- a/pkg/vm/engine/disttae/txn_table.go
+++ b/pkg/vm/engine/disttae/txn_table.go
@@ -2393,6 +2393,11 @@
return rds, nil
}
+ // Diagnostic observer supplied only by the external issue32515 probe overlay.
+ if observe, ok := ctx.Value("issue32515.reader-rel-data-observer").(func(uint64, engine.RelData, *plan.Expr, types.TS)); ok {
+ observe(tbl.tableId, relData, expr, types.TimestampToTS(tbl.db.op.SnapshotTS()))
+ }
+
blkCnt := relData.DataCnt()
newNum := num
if blkCnt < num {Attachment3: exact-budget-only.diff (complete, diagnostic only)
--- a/pkg/vm/engine/disttae/logtailreplay/rows_iter.go
+++ b/pkg/vm/engine/disttae/logtailreplay/rows_iter.go
@@ -221,7 +221,6 @@
}
first := true
- cnt := 3
spec := PrimaryKeyMatchSpec{
Name: "Exact",
moveInner: func(p *primaryKeyIter) bool {
@@ -238,10 +237,6 @@
} else {
ok = p.iter.Next()
-
- if !p.specHint.isDelIter {
- cnt--
- }
// Note that:
// delete a pk may happen twice, means there may have two deletes
@@ -258,7 +253,7 @@
//
// if the Exact only consider the latest one records, it may miss the insert!
//
- if !ok || cnt <= 0 {
+ if !ok {
return false
}
}
Activity
LeftHandCold commentedon Nov 13, 2026
本轮已补齐当前 main 的实际复现与修复验证,不再只是对比 4.2/main 的函数源码。修复 PR:#32668,目标分支
main,提交50bb07caae467c08b951154757933323e5c607fa。根因与影响
验证基线为
main@6c7457903d9e6e259b6b51e749fecc0ff8a59ea5。Exact将三条历史候选当作查找预算,但较新的 transferred DELETE 可能指向其他旧物理 RowID,并不代表当前逻辑主键不存在。预算在这些删除记录上耗尽后,第四条有效 INSERT 根本没有进入isPKItemValid,SQL 因而成功返回空集。这是读路径的 silent wrong result,普通 SELECT 与 SELECT FOR UPDATE 都受影响。当前证据不是持久化数据丢失,也没有证明会产生重复自增值。
固定计数的源码引入点是 2024-10-30 的 #19658(
694718a1bd)。这证明该算法限制长期存在;没有执行两年前版本的服务 A/B,不能将其表述为最近某个 PR 新引入的生产回归。main 实际 SQL 红绿对照
在 50 上,使用相同 main 源码、匹配的 native build、Go 1.27.1、
GOMAXPROCS=2,执行真实 TAE -> logtail -> InternalSQLExecutor 链路。四个阶段各执行四种 SQL,共 16 次查询;每个阶段共享一个固定 SI 事务快照。最后阶段的结果:
(3,1)(3,1)(3,1)(3,1)(3,1)(3,1)未修复版只有最后阶段两个完整 PK 断言失败;修复后 16/16 通过。独立 handler-fed UT 也确认 0/1/2 条较新删除通过,3/8 条时原实现漏行。
修复边界
只修改 CN
Exact的迭代终止条件,不修改 TN、Flush、提交、锁协议或 incrservice/FATAL:ExactNonUnique不变。验证与性能
pkg/vm/engine/disttae/logtailreplay全包通过,0.594 秒。pkg/vm/engine/test全包通过,171.447 秒;原有 3 个 skip 未算作通过。.golangci.yml检查两个包:0 issues,无新增豁免。必须保留的未知
SQL 复现显式驱动 Flush 并暂缓三次提交,未传入源 tombstone objects;RPC/锁使用现有测试适配器。它不是正常自动调度或多 CN 锁冲突的复现。正常 flusher 有 oldest-first、tombstone 选择和 object scope 冲突控制,生产中同样历史序列的到达路径和发生频率尚未证实。
本轮能确定并修复的是 #32660 的读取算法错误;不能因此宣布 #32515 根因已经找到或已经解决。自审已检查全部改动、唯一/非唯一调用边界、资源释放和热路径成本,没有发现阻塞项;GitHub CI 仍需另行验收。
LeftHandCold commentedon Nov 13, 2026
已提交
4.2-dev回移 PR:#32692,来源为 Main #32668 的50bb07caae。目标基线
2397892f71a937903f72dab41bd2199479102eef,回移提交87684f90b51d60a4c094778447d089f2c416a9b4。git cherry-pick -x无冲突,三个文件原样回移,没有额外带入 Main 功能或修改 TN/Flush/锁/FATAL 逻辑。这次在 50 上重新验证了 4.2 自身的修复前后行为,没有用 Main CI 代替:
(3,1)。logtailreplay全包通过(0.278 秒),engine/test全包通过(155.151 秒);原有 4 个 skip 未计作通过。自审无阻塞项,GitHub CI 尚需独立验收,未合并或部署。
继续保留原证据边界:SQL fixture 手动控制三次 Flush 提交且未传 source tombstone objects;未证明正常自动调度下的触发频率,也不能据此认定 #32515 已定位或修复。
fix(disttae): preserve exact PK reads across transferred deletes (#32668
XuPeng-SH commentedon Nov 14, 2026
本轮合并范围核对:#32668 已合入 main,merge SHA
0e8d3ca2bf677d395ca3b42f0f13ca27aca008db,最终 PR head922362141b143e3d82e1392035a2e25de3ef258a。修复范围是 CN Exact 候选迭代,不代表 #32515 生产事故或 TN 点查现象已经解决。现有评论已记录的 4.2-dev 回移 #32692 当前仍 open、未合并,因此本 issue 暂保留研发负责人,不作全部版本完成或验收通过的结论。这是已有开发 follow-up,不是因转测新增 backport 要求。
验证证据应分别使用:作者在 main 基线报告受控 SQL 16/16、相关两包与固定版本 lint;独立评审 5899445379 针对较早的
abe333824c4787f0ee0038bb84a5e279f50ea077报告 logtailreplay 588 个测试/子测试、1 个 skip,以及受控 SQL 16/16 和额外历史/GC 探针。不能把该评审写成最终 head 的重新实测。本轮仅核对远端状态、源码差异和讨论,没有本地运行测试,也不声明最终 CI 全绿。后续 QA 应区分相同快照下 exact / FOR UPDATE / prefix / full 的结果,覆盖真删除、重插、旧快照及长 transferred-delete 前缀。正常自动 flusher 可达性/频率、多 CN 锁冲突和生产尾延迟仍未由受控 fixture 证明;原 TN GetValueByFilter 与 HybridScan 差异也不在本修复闭环内。
[4.2-dev] fix(disttae): preserve exact PK reads across transferred de…