Skip to content

[Bug]: Secondary-index GetBind timeouts leave No-PK Sysbench fixture incomplete and cause base scans #29621

Closed

Description

@LeftHandCold
  • I have checked the existing issues.

Correction, 2026-10-05: the original body incorrectly treated Creating a secondary index as a success receipt. It is a pre-execution message. Both the client and CN logs show CREATE INDEX k_1 ON sbtest1(k) failed. The access-path change is explained by failed fixture preparation, not a proven optimizer/Prepared regression. The index-build RPC timeout remains a real availability failure requiring separate attribution.

Branch Name

4.2-dev. Main is a control, not a confirmed affected branch or a confirmed fix for this incident.

Commit ID

  • Slow 4.2 run: 6dc70318bb26ae43f8969cc565886b40d532e590.
  • Previous, fast 4.2 run: 0de7c54a043a93ef5ff3d5fdba30a5640dda8100.
  • Contemporaneous main control: 21f711a7b852238394417e547282e14dce8660d9.
  • Latest main inspected: 37ba0712974d4a1ebe3fe8cd8e6a4daba7400f5e.

Other Environment Information

  • TKE Family Daily, one TP CN and two AP CNs; this Sysbench workload is routed to TP.
  • TP CN: 14 CPU, 55Gi container memory, 16Gi FileService Memory Cache.
  • Slow namespace: mo-42-family-37215504171-1; TP pod: nightly-regression-dis-tp-cn-tkbkn.
  • Previous namespace: mo-42-family-37136478265-1; TP pod: nightly-regression-dis-tp-cn-422x6.
  • Same mo-sysbench revision: 1a7886fc7566dfc9fd85a81801f09471151365d3.
  • Ten tables of 10,000,000 rows each; secondary=on, auto_inc=off, create_secondary=on.
  • select_random_points.lua, 1,000 threads, configured duration 300s. This Lua case queries sbtest1 only, despite preparing ten tables.
  • Binary prepared SQL, ten integer parameters:
SELECT id,k,c,pad FROM sbtest1 WHERE k IN (?,?,?,?,?,?,?,?,?,?);

Actual Behavior

The No-PK random-points query phase suffered an approximately 400x throughput collapse, with no query errors. However, its preparation had already failed to build the required k_1 index. The harness accepted the incomplete fixture and continued benchmarking a base-table scan.

Run Case UTC window TPS Queries Average latency Errors
Previous 37136478265 / 111274199705 Oct 3, 20:17:29-20:22:31 3373.75 1,014,596 295.82ms 0
Slow 37215504171 / 111509552680 Oct 4, 20:09:52-20:16:40 8.42 3,425 104,655.85ms 0

Slow-run Sysbench total time is 406.846s, maximum latency 128,887.63ms. Outstanding requests extend completion beyond the configured 300s measurement duration.

1. Required index creation failed, but preparation was accepted

Exact raw log from the slow job, UTC on Oct 4:

20:04:12.408 Creating a secondary index on 'sbtest1'...
20:04:24.214 FATAL: mysql_drv_query() returned error 20101
  context deadline exceeded
  internal error: getLockTableBind
  for query 'CREATE INDEX k_1 ON sbtest1(k)'
20:04:47.879 PREPARE PASS
20:04:48.418 no-primary-key rows=100000000 invalid_ddl=0
20:09:52     random-points query phase begins

The same prepare phase failed CREATE INDEX for k_1, k_5, k_9, k_10, k_7 and k_4. The previous run's prepare log has no corresponding FATAL errors. The slow run's handoff records case_exit_code=0, cleanup_result=retained, handoff_safe=true despite those failures.

Independent TP CN evidence at 20:04:24.211986 UTC:

caller: compile/sql_executor.go:181
msg: internal sql executor error
sql: insert into `tke_family_weekly_sysbench`.`__mo_index_secondary_01a10884-5593-70d7-8638-40946dd676ce`
     select serial_full(`k`,`__mo_fake_pk_col`), `__mo_fake_pk_col`
     from `tke_family_weekly_sysbench`.`sbtest1`;
error: context deadline exceeded / getLockTableBind
txn: c5804585c1bab7c618db6075c3aee3d2

At 20:04:24.212234 the frontend records CREATE INDEX k_1 ON sbtest1(k) with status=fail, same transaction, statement ID 01a10884-5592-7b69-bb4b-40e70a0acc98.

At the running revision, doCreateIndex propagates this backfill error before UpdateConstraint and index-catalog publication. An unsuccessful build is not a usable index. The following benchmark steps do not retry/build it.

The exact nightly prepare script does not inspect prepare output for FATAL errors. Its no-PK contract checks row counts/id range and absence of a declared primary key, but does not check the required k indexes. The query-phase runner does check FATAL errors; that does not repair the preparation gap.

The preceding id point-select remains at 9406.85 -> 8907.99 TPS. This is not evidence that k_1 exists: the xid(id) index is established in CREATE TABLE, whereas k_1(k) is a later, failed DDL. The following auto-increment case creates a separate fixture and remains at 8586.05 -> 8012.74 TPS.

2. Slow requests repeatedly select 1,222 base-table blocks

Example from the TP CN at Oct 4, 20:10:12.207611 UTC:

caller: disttae/txn_table.go:1058
msg: txn.table.ranges.log
name: sbtest1
tbl-id: 273405
exprs: in(Expr_Col(sbtest1.k.1), Expr_Fold(id=1))
blocks: 1222
cost: 841.191us

The same base-table/1,222-block shape occurs across many transactions, including late in the case. The sub-millisecond ranges cost is not the overall query cost. blocks records selected ranges, not a separately measured count of physical disk reads.

The recorded storage predicate is plain IN on k, not a visible CAST(k) expression. Do not automatically import the column-cast/random-range diagnosis from #29606.

3. CPU profiles independently show index access versus scan/materialization

Both windows are two minutes inside the respective random-points case. Percentages are cumulative and nested; do not add them.

Symbol Previous 4.2, 20:19-20:21 UTC Slow 4.2, 20:12-20:14 UTC
indexjoin.(*IndexJoin).Call 66.71% No sampled frame
blockio.materializeBlockData 5.92% 71.04%
objectio.CopyCachedVectorAll 0.003% 43.71%
table_scan.(*TableScan).evalFilter 2.21% 21.86%
opOperatorFixedIn.operatorIn 0.17% 18.79%

These profiles and ranges are the expected downstream consequence of the missing usable k index. They do not require an NDV/Outcnt regression to explain the incident. No exact historical COM_STMT_EXECUTE plan was retained; index-build failure, publication order, absence of a workflow retry, and sustained base-scan evidence establish the access-path explanation.

4. Same-data counterfactual on an isolated instance

On Oct 5, a run-owned container on server 50 used the exact slow image commit-6dc70318bb26ae43f8969cc565886b40d532e590, a single 10M-row no-PK table, and a real binary Prepared query with ten integer bindings 4000000..4000009. No kernel, optimizer statistics, or base rows were changed in this test.

Change to the same fixture Median of five executions Result
k_1 absent 3.626240s 8 rows
create k_1 successfully 0.001337s same 8 rows
drop k_1 again, after warmup 3.482405s same 8 rows

All 15 executions have the same complete-row multiset SHA-256: 7c70c4bc1b7a179ddc6a6e36278783351b0b6e69466631551c60a6e119867175. The literal plan control changes from plain base Table Scan to Join Type: INDEX plus Index Table Scan on sbtest1.k_1, then back. The timed queries use binary Prepared execution, not that literal EXPLAIN.

This is a counterfactual for the access-path consequence, not a reproduction of the distributed GetBind timeout or the exact 1,000-thread TKE throughput. The isolated instance has 4 CPU/12Gi and different cache/physical data; preparation used locally installed Sysbench 1.0.20 rather than TKE's 1.1.0-de18a03. Absolute TPS from these environments is not comparable. Separate synthetic statistics-patch experiments are not incident attribution evidence.

Expected Behavior

The prepare phase must not announce success or release a fixture to an index-performance test after required index creation fails. Preserve the server's DDL error and validate the required index metadata before publishing an indexed-performance result.

The MO-side failure to investigate is the GetBind RPC timeout during secondary-index backfill. This issue does not assert that failing a DDL incorrectly removes a previously committed index, that the query optimizer ignored a healthy index, that results were wrong, or that a specific new PR introduced the timeout.

Steps to Reproduce

Historical distributed timeout conditions, not a deterministic timeout reproducer:

  1. Use the special Sysbench Family case from the linked run and the frozen tool revision above.
  2. Prepare 10 x 10M rows with no declared primary key, an id secondary index, and attempt to create each k secondary index (secondary=on auto_inc=off create_secondary=on).
  3. Keep the original sequence: No-PK point-select followed by select_random_points.lua, 1,000 threads, 300s.
  4. Preserve each CREATE INDEX terminal status, index metadata, CN/TN GetBind request/response timing, RPC queues, profiles, and the prepare handoff before cleanup.
  5. For the deterministic access-path control only: on a run-owned isolated table, compare missing k_1 -> successful CREATE INDEX k_1 -> missing k_1 again with fixed binary bindings. Do not inject missing indexes into a shared/production fixture.

The nightly prepare uses randomly generated data and fresh physical objects. The two historical runs are not a same-data binary A/B.

Additional information

Timeout boundary and remaining unknowns

getLockTableBindWithContext creates a GetBind request with the existing 10s RPC budget and propagates transport/future failure. This is not a 300s query timeout or a captured row-lock deadlock.

TN was running, continued processing commits, and recorded new lock-table binds during the failing interval. Around the failures TN used about 3.6-3.7 CPU cores; TP used about 10.2 of its 14 cores. Go GC maximum-pause samples were below 0.1s on TP and approximately 0.18s on TN, not a captured 10s stop-the-world pause. No OOM/restart was observed. These facts do not distinguish response delivery, RPC scheduling, host pressure or a deeper LockService defect.

The exact reason the GetBind futures expired is still unproven. Do not replace that unknown with a generic network claim, nor assume TN was completely stuck because the client timed out.

Only #29504 (backup) and #29605 (SQL source provenance) lie between the two 4.2 images. The optimizer, readutil and materialization paths above did not change in that interval. This does not prove neither PR can matter indirectly, but it is insufficient to name either as the introducing commit.

Main status and related issues

Classification: proven preparation/evidence defect and explained missing-index scan consequence; real index-build availability failure with an unproven deeper RPC cause. The historical 3374 -> 8 TPS observation is not a valid same-schema performance regression A/B. No introducing commit has been pinned; do not revert #29605 on this evidence.

Activity

  1. added
    kind/bug
    on Oct 5, 2026
  2. changed the title [-][Bug]: 4.2 No-PK prepared random-points falls from 3374 to 8 TPS with base-table scan/materialization[/-] [+][Bug]: Secondary-index GetBind timeouts leave No-PK Sysbench fixture incomplete and cause base scans[/+] on Oct 5, 2026
  3. LeftHandCold commented on Oct 5, 2026

    @LeftHandCold
    CollaboratorAuthor

    Root-cause update and correction

    I need to correct a material error in the initial report: Creating a secondary index is printed before running CREATE INDEX; it is not a successful-build receipt. The original exclusion of missing-index setup was wrong. The issue body and title have been updated to preserve that correction explicitly.

    The slow run's raw prepare log records:

    2026-10-04 20:04:12.408 UTC: Creating a secondary index on 'sbtest1'...
    2026-10-04 20:04:24.214 UTC: FATAL ... getLockTableBind
      for query 'CREATE INDEX k_1 ON sbtest1(k)'
    2026-10-04 20:04:47.879 UTC: PREPARE PASS
    2026-10-04 20:04:48.418 UTC: rows=100000000 invalid_ddl=0
    

    All six failed index builds are k_1, k_5, k_9, k_10, k_7, k_4. The original job and retained prepare-on-off-on.log contain these errors; they are not inferred from CPU profiles.

    CN independently records the failed k_1 index-backfill INSERT, failed CREATE INDEX terminal status, and rollback of transaction c5804585c1bab7c618db6075c3aee3d2. At the running commit, backfill failure returns before publishing the index constraint/catalog. The subsequent benchmark steps do not rebuild it. The prepare oracle checks rows/id bounds/no primary key, but not the required k index.

    That closes the performance chain:

    GetBind timeout during index build -> no usable k_1 -> false prepare success -> random-points base scan -> repeated 1,222-block materialization/IN filtering under 1,000 concurrency.

    The healthy id point-select does not contradict this: it uses xid(id), created with the base table, not the later k_1(k).

    Real same-data counterfactual

    On a run-owned, isolated server-50 container using the exact slow MO image, I kept the same 10M base rows and binary Prepared bindings 4000000..4000009. No optimizer statistics or MO code were changed:

    Fixture state Median, five executions
    k_1 absent 3.626240s
    k_1 successfully created 0.001337s
    k_1 removed again after warmup 3.482405s

    Every execution returns the same 8 complete rows with the same row-multiset SHA-256. The independent literal EXPLAIN control changes Table Scan -> INDEX Join -> Table Scan. The timing is for real binary Prepared execution, not EXPLAIN.

    This validates the missing-index scan consequence; it is not a reproduction of the original distributed GetBind timeout or exact TKE TPS. The isolated CPU/memory/cache, physical data and preparation Sysbench version differ. Earlier synthetic NDV-patch experiments do not identify this incident's cause.

    Attribution boundary

    • The historical 3374 -> 8 TPS pair is not a valid indexed-query performance A/B, because the required index state differs.
    • There is no evidence pinning [4.2-dev] fix(frontend): preserve SQL source through policy rewrite #29605 as the introducing performance-regression commit. Reverting it or changing query-cache/optimizer algorithms based on this run is not justified.
    • The MO-side index-build failure is real. GetBind has a 10s RPC budget, but the deeper reason for those futures expiring is not yet pinned. TN continued processing commits/new binds; no OOM, restart or captured 10s GC pause explains the window.
    • Main's successful indexed control is not proof that it fixes this timeout mechanism.

    The first low-risk harness improvement is to fail prepare on its worker errors and validate required indexes before running/publishing the indexed benchmark. Kernel changes should wait for request/response/queue evidence identifying the actual GetBind failure owner.

  4. LeftHandCold commented on Oct 5, 2026

    @LeftHandCold
    CollaboratorAuthor

    Follow-up: harness fix validated; allocator timeout remains under investigation

    The false-success harness defect has been fixed in mo-nightly-regression#1758, primary fix d3719b76, latest head 1390f0b8 (one-line update to an existing SQL test double):

    • Preserve prepare stderr and reject fatal worker errors even if Sysbench exits zero.
    • Verify all ten required visible k_N(k) indexes before announcing PREPARE PASS when secondary-index preparation is requested.
    • Recheck required indexes before a retained no-PK random-points workload. Missing or unavailable metadata prevents workload execution and performance publication, and follows existing failed-fixture cleanup.
    • Keep intentional index-free scenarios, workload parameters, timeout budgets and deferred physical GC unchanged.

    Validation on server 50:

    • The unmodified helper accepts the injected zero-exit FATAL and missing-index fixtures; the patched helper rejects them.
    • Existing isolation module: 13 tests passed. Complete TKE Python suite: 368 tests, OK, 6 optional external-fixture checks skipped. Existing Sysbench clone contract and ShellCheck passed.
    • All 29 existing TKE shell harnesses and the Warm Session contract harness passed. Initial CI exposed an existing SQL test double returning generic OK for the new index query; the latest head supplies its expected index count. The real admission check was not relaxed.
    • Latest-head Linux contracts CI passed. Optional Warm load jobs were not selected and are not claimed as executed.
    • Real incident image 6dc70318bb26ae43f8969cc565886b40d532e590, isolated 4 CPU/12Gi instance: the actual helper prepared ten 100,000-row tables and verified ten real k indexes. Dropping only k_6 then invoking random-points failed at table=sbtest6 index=k_6 expected=1 actual=0, made no benchmark invocation, and removed the owned test database. The endpoint adapter changed only the isolated port, not SQL/results.

    Additional MO-side evidence

    The same TP CN also logged doKeepLockTableBind deadline failures at 20:04:19.845, 20:04:25.778, 20:04:31.794 and 20:04:37.729 UTC on Oct 4. Exact-version code sends both GetBind and KeepLockTableBind through the ordinary allocator lock-client path; do not confuse binding renewal with the separate KeepRemoteLock transport. This is not just a large backfill query exceeding its SQL time budget.

    TN continued processing commits and creating binds during the failure window, and aggregate lock RPC counters continued advancing. Sampled ordinary TP lock-client active requests reached 5 at 20:04:30/45 and returned to zero by 20:05:00; its connect/close counters each increased once. Sampled sending queues did not show sustained backlog. These observations narrow the investigation but do not identify the stalled request/connection.

    Important evidence limit: the server mo_rpc_message_total{type="send"} counter increments before socket write. Matched aggregate send/receive counts cannot prove delivery of a particular GetBind response. The original INFO logs do not give a common request ID and terminal response write/receive for the failed index. A TN bind at 20:04:14.204437 and the first confirmed backfill failure at 20:04:24.211986 are approximately ten seconds apart, but there is no direct table-ID/request-ID link proving they are the same RPC.

    Proven: GetBind timeout -> failed index DDL -> incomplete fixture incorrectly admitted by the old harness -> base-table scan / very low random-points throughput. The harness admission defect is independently reproduced and fixed.

    Still unproven: why those allocator futures expired, whether that deeper failure is a MO transport/scheduling defect or an external connectivity interruption, and which commit introduced it. The successful small-instance preparation is not a distributed timeout reproduction. This PR does not claim to fix the allocator failure or establish a #29605 performance regression; keep the MO-side investigation open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions