pingcap / pingcap/tiflash

Avoid too many remote read when resolve (async commit) lock failed

Open
#3,782 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/enhancement
Dominant language
C++
Stars
1k
Forks
423
Avg merge
1d 15h
Merged PRs (30d)
24

Description

Enhancement

In a product env, TiFlash meet lots of lock error and make lots of remote read ...

"CheckSecondaryLocks error: Exception: CheckSecondaryLocks receives a non-async-commit lock"
"CheckSecondaryLocks error: Exception: server busy"
"resolve txn failed: Exception: resolveAsyncLock failed"

image
image

... Finally, those remote reads consume all threads resource and make TiFlash crash.
image


After the resolve lock fails in one TiFlash node within the backoff retry, even if the remote read is used to resolve lock on another tiflash node, the other tiflash nodes will still fail with a high probability.

Instead of generating a remote read and causing the tiflash process to crash, we can terminate the SQL quickly by throwing an error directly to TiDB when a lock-related error is encountered during the resolve lock phase. This could avoid making TiFlash crashes when meeting locks.

https://github.com/pingcap/tics/blob/e406fb4b086869f54823d179ef26ded92563fdfc/dbms/src/Storages/Transaction/LearnerRead.cpp#L67-L74

https://github.com/pingcap/tics/blob/e406fb4b086869f54823d179ef26ded92563fdfc/dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp#L214-L219

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading dbms/src/Storages/Transaction/LearnerRead.cpp around lines 67-74 and dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp around lines 214-219. Trace how lock-related errors during async-commit resolution lead to remote reads and review the reported failure messages. Done means the SQL terminates with an error instead of generating further remote reads when lock resolution fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
databases, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.