Build1 distinct publisher3 min readUpdated
Mercari's DBRE team found the query only after switching a batch read endpoint to TiDB. Query replay had run first and had not flagged it.
The Engineer · Build desk

Compiled by The EngineerSomething wrong?How this is made
Mercari's Database Reliability Engineering team moved a high-load batch read endpoint from MySQL to TiDB and then watched query speed degrade sharply on an hourly cycle, with MySQL-to-TiDB sync lag and commit durations rising at the same moments [3][6][7]. The cause was a single query whose Index Join generated an internal IN list of close to one million elements, and the damage did not stay inside that query [8][11].
That last point is the operational one. Normally a bad query hurts itself and its neighbours; here reads and writes unrelated to the offending statement slowed too, which is why the team treated it as a cluster stability problem rather than a tuning ticket [9][10]. TiDB Cloud support traced it to Protobuf deserialization in TiKV's gRPC threads: the oversized IN clause monopolised those threads, so every subsequent request sharing them queued, and cluster latency spiked [12].
The timing was unhelpful. The incident surfaced immediately before Mercari's largest cluster switchover, during a period when MySQL and TiDB ran in parallel and some endpoints had already been pointed at TiDB [2]. The cutover plan had three steps in order: OLAP read endpoints, OLTP read endpoints, then writes [4]. The team was still on step one [5], which leaves two of the three phases ahead of them [20]. And before switching, they had replayed ProxySQL's live MySQL traffic against TiDB with an in-house tool, checking both query compatibility and TiDB load, and fixed what that found [c5a]. The post says it will explain why replay did not catch this one; the published excerpt stops before the explanation [19].
Containment was fast because it had been planned for. The team read the slow query list, identified the query, and used ProxySQL's mysql_query_rules to route that one query digest back to MySQL, an operation they had anticipated in the migration plan and still use [13][14]. Two caveats worth copying into your own runbook: you cannot redirect a single query inside a transaction this way [15], and ProxySQL's digests are not compatible with those from pt-query-digest or TiDB, so you have to read the digest out of stats_mysql_query_digest and paste that exact value into the rule [16].
PingCAP's first-aid was to cap scan-range memory with tidb_opt_range_max_size = 1048576, which is one mebibyte [17][21], and to reduce Index Join parallelism with tidb_index_lookup_join_concurrency = 2, a variable now deprecated in favour of tidb_executor_concurrency [17]. The team also priced up resource control to deprioritise the query and scaling TiKV up, and concluded that all of the no-code-change workarounds contributed only marginally [c18a][18]. The actual fix was to stop shipping a million IDs through gRPC at all: store them in a temporary table instead of embedding them in SQL [c18b]. That required application work, which meant interrupting a product team's priorities with no guaranteed completion date [c18c].
Reproducing the problem cost real effort too. Building an independent cluster carrying the same data hit resource exhaustion, repeated restore failures against bandwidth quotas, and a data pipeline that fell behind while catching up, because a new TiCDC changefeed's load was not isolated from the changefeed already in production [22][23].
Watch for the follow-up posts: the changefeed isolation writeup, and whether the OLTP read and write cutovers turn up more query shapes that only misbehave at production scale.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
Mercari completed a migration of its CoreDB from MySQL to TiDB, and its DBRE team is publishing three articles on improvements made through the end of March 2026.
The incident was discovered immediately before Mercari's largest cluster switchover, during a period when MySQL and TiDB were operated in parallel and endpoints for some queries had already been switched to TiDB ahead of the rest.
After switching the batch endpoint from MySQL to TiDB, there were periods every hour in which query speed degraded markedly.
The planned cutover order was: read endpoints for OLAP traffic, then read endpoints for OLTP traffic, then write endpoints.
At the time the problem occurred the team was executing step 1, specifically switching a comparatively high-load read endpoint called the batch endpoint from MySQL to TiDB.
Before the switch, the team used an in-house tool to replay traffic flowing to MySQL via ProxySQL against TiDB, checking query compatibility problems and TiDB load for the OLAP endpoints in advance and addressing the issues found.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Detailed first-party postmortem, no external corroboration
The single source is a specific, mechanism-level account naming the failing component (Protobuf deserialization on TiKV gRPC threads), the exact mitigation variables and values, the ProxySQL rule mechanics, and the accepted fix, plus candid unresolved items. What is missing is any quantified impact (latency figures, duration, affected traffic share), any second publisher, and any upstream issue or vendor-side confirmation of the gRPC thread behaviour, so the mechanism rests wholly on Mercari's telling of its joint investigation with PingCAP.
Real production deployment, single-organisation scope
Adoption evidence is concrete but confined to one company: a completed CoreDB migration to TiDB with phased endpoint cutover, an ongoing production use of ProxySQL digest rerouting, a shipped temporary-table application fix (two such cases total at Mercari), TiCDC changefeeds in production, and a deletion tool processing over 100 million records per day. No other organisations, downloads, or usage figures are supplied, so this is deep but narrow adoption signal.
Understated: engineering detail without promotional framing
The post makes no product or capability boast; it documents a failure in the publisher's own migration, records that the low-effort mitigations barely helped, admits the reproduction cluster failed to insulate production, and concedes the replay detection gap was never explained. Claims are, if anything, narrower than the evidence presented, which is why the gap sits slightly negative rather than at zero. The mild counterweight is the crediting of TiDB Cloud support without independent confirmation.
First-party engineering blog with vendor relationship
The publisher is the affected operator, so there are ordinary employer-branding and recruiting incentives, plus an existing commercial relationship with the TiDB Cloud vendor that is thanked for its help; the write-up also trails two further posts in a series. Those incentives are visible but modest in effect here, since the content centres on the publisher's own operational failures and on a deprecated-variable caveat that cuts against vendor-flattering simplicity.
Coherent single-source account, limited verification
Internal consistency is high: symptoms, root cause, mitigation and fix form a plausible causal chain with specific technical detail, and the acknowledged unknowns are clearly bounded. Confidence is capped by having one publisher, no quantified metrics, no external or upstream corroboration of the TiKV gRPC behaviour, and two threads (the replay miss and the TiCDC changefeed interference) explicitly deferred or unresolved.
build
TiDB quietly turns primary-key ORDER BY into a TopN, and the fix is not in v8.5.71 distinct publisher
build
Mercari's TiDB gains came from storage knobs, while plan caching went back off1 distinct publisher
build
Your meter now runs on someone else's machine: signed receipts, fsync, and failing open1 distinct publisher
build
Slow Magento reindexes are a price index problem, and raw SQL makes it worse1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
1 article · August 17, 2026