Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource_control: bypass some internal urgent request #884

Merged
merged 6 commits into from
Jul 14, 2023

Conversation

nolouch
Copy link
Contributor

@nolouch nolouch commented Jul 12, 2023

Background

In tidb, the source request will be tiny but urgent. we can consider skip it by resource control

const (
	// InternalTxnOthers is the type of requests that consume low resources.
	// This reduces the size of metrics.
	InternalTxnOthers = util.InternalTxnOthers
	// InternalTxnBootstrap is the type of TiDB bootstrap txns.
	InternalTxnBootstrap = InternalTxnOthers
	// InternalTxnMeta is the type of the miscellaneous meta usage.
	InternalTxnMeta = util.InternalTxnMeta ==> util.InternalTxnOthers
	// InternalTxnCacheTable is the type of cache table usage.
	InternalTxnCacheTable = InternalTxnOthers
	// InternalTxnBindInfo is the type of bind info txn.
	InternalTxnBindInfo = InternalTxnOthers
	// InternalTxnSysVar is the type of sys var txn.
	InternalTxnSysVar = InternalTxnOthers
	// InternalTxnTelemetry is the type of telemetry.
	InternalTxnTelemetry = InternalTxnOthers
	// InternalTxnPrivilege is the type of privilege txn.
	InternalTxnPrivilege = InternalTxnOthers
)

As the upper show, bootstrap, cached table, bindinfo, sysvar, telemetry, privilege, meta relative internal SQL can be skipped first.
Search code with kv.WithInternalSourceType(context.Background(), kv.InternalTxnBindInfo) can see the origin of the SQL.

Manual Test:

It's based on cse repo. I set the group with low RU:

  {
    "name": "1",
    "mode": 1,
    "r_u_settings": {
      "r_u": {
        "settings": {
          "fill_rate": 0
          "burst_limit": 1
        },
        "state": {
          "last_update": "2023-07-14T01:23:21.99892+08:00",
          "initialized": true
        }
      }
    },
    "priority": 0
  }

Before:

image

After
image

@nolouch nolouch changed the base branch from master to cse-region-client July 12, 2023 11:11
@nolouch nolouch closed this Jul 13, 2023
@nolouch nolouch reopened this Jul 13, 2023
nolouch added 2 commits July 14, 2023 03:33
Signed-off-by: nolouch <[email protected]>
Signed-off-by: nolouch <[email protected]>
@nolouch nolouch changed the title Cse add bypass resource_control: bypass some internal urgent request Jul 14, 2023
@nolouch nolouch marked this pull request as ready for review July 14, 2023 08:10
util/request_source.go Outdated Show resolved Hide resolved
Signed-off-by: nolouch <[email protected]>
@zeminzhou
Copy link
Contributor

Can this pr fix Error 8027 (HY000): Information schema is out of date: schema failed to update in 1 lease, please make sure TiDB can connect to TiKV.?

@nolouch
Copy link
Contributor Author

nolouch commented Jul 14, 2023

I think Information schema is out of date should pass the DDL.

@zeminzhou
Copy link
Contributor

If we do it, all DDL will be bypass?

@nolouch
Copy link
Contributor Author

nolouch commented Jul 14, 2023

@zeminzhou I checked it, it's relative to the reload of the schema from tikv, and it will label as util. InternalTxnMeta, it's belongs to InternalTxnOthers, so I think This PR will fix the reported error.

@ystaticy
Copy link
Contributor

How about bypass ddl request in this PR ?

@zeminzhou
Copy link
Contributor

That's great, thanks!

Signed-off-by: nolouch <[email protected]>
@nolouch
Copy link
Contributor Author

nolouch commented Jul 14, 2023

commit 7b5da57
is cherry-pick from #868 to make tidb-compatibility pass.

Copy link
Contributor

@zeminzhou zeminzhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~

@iosmanthus iosmanthus merged commit 19ef437 into tikv:cse-region-client Jul 14, 2023
@nolouch nolouch deleted the cse-add-bypass branch July 14, 2023 16:40
nolouch added a commit to nolouch/client-go that referenced this pull request Aug 11, 2023
nolouch added a commit to nolouch/client-go that referenced this pull request Aug 11, 2023
iosmanthus pushed a commit that referenced this pull request Aug 11, 2023
* resource_control: bypass some internal urgent request (#884)

Signed-off-by: nolouch <[email protected]>

* resourcecontrol: fix nil pointer (#900)

Signed-off-by: nolouch <[email protected]>

---------

Signed-off-by: nolouch <[email protected]>
iosmanthus added a commit that referenced this pull request Aug 11, 2023
* client-go: add some key range info to error when PD returned no region (#862)

Signed-off-by: Chao Wang <[email protected]>

* *: refine non-global stale-read request retry logic (#863)

Signed-off-by: crazycs520 <[email protected]>

* Fix the issue that primary pessimistic lock may be left not cleared after GC (#866)

* Fix the issue that primary pessimistic lock may be left not cleared after GC

Signed-off-by: MyonKeminta <[email protected]>

* Fix mysteriously shown up thing that makes compilation failed

Signed-off-by: MyonKeminta <[email protected]>

* Fix test effectiveness (forgot to set txn2 to pessimistic txn); add more strict checks

Signed-off-by: MyonKeminta <[email protected]>

* Address comments

Signed-off-by: MyonKeminta <[email protected]>

---------

Signed-off-by: MyonKeminta <[email protected]>
Co-authored-by: MyonKeminta <[email protected]>

* add explicit request source type to label the external request like lightning/br (#868)

Signed-off-by: nolouch <[email protected]>

* use '%d' instead of '%q' for some int values in error message (#875)

Signed-off-by: Chao Wang <[email protected]>

* format key in error message in method `scanRegions` (#876)

Signed-off-by: Chao Wang <[email protected]>

* make cop request timeout a config paramter (#865)

* update

Signed-off-by: Spade A <[email protected]>

* update

Signed-off-by: Spade A <[email protected]>

* update

Signed-off-by: Spade A <[email protected]>

* update

Signed-off-by: Spade A <[email protected]>

---------

Signed-off-by: Spade A <[email protected]>

* region_cache: support check pending tiflash peer (#821)

Signed-off-by: guo-shaoge <[email protected]>
Co-authored-by: disksing <[email protected]>

* *: add `SnapshotIterReverse` and make `iterReverse` supports `lowerBound` (#883)

Signed-off-by: Jason Mo <[email protected]>

* *: fix stale read ops metric (#878) (#889)

Signed-off-by: crazycs520 <[email protected]>
Co-authored-by: disksing <[email protected]>

* add gc options (#828)

Signed-off-by: weedge <[email protected]>
Co-authored-by: disksing <[email protected]>

* reload region cache when store is resolved from invalid status (#843)

Signed-off-by: you06 <[email protected]>
Co-authored-by: disksing <[email protected]>

* ci: update setup-go action (#904)

Signed-off-by: disksing <[email protected]>

* fix unexpected slow query during GC running after stop 1 tikv-server (#899) (#909)

* fix unexpected slow query during GC running after stop 1 tikv-server

Signed-off-by: crazycs520 <[email protected]>

* fix test

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>

* resource_manager: ignore ru metrics for background request (#872)

Signed-off-by: husharp <[email protected]>
Co-authored-by: disksing <[email protected]>

* add more log for diagnose (#915)

* add more log for diagnose

Signed-off-by: crazycs520 <[email protected]>

* fix

Signed-off-by: crazycs520 <[email protected]>

* add more log for diagnose

Signed-off-by: crazycs520 <[email protected]>

* add more log

Signed-off-by: crazycs520 <[email protected]>

* address comment

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>

* use context logger as much as possible (#908)

* use context logger as much as possible

Signed-off-by: crazycs520 <[email protected]>

* refine

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>

* Resume max retry time check for stale read retry with leader option(#903) (#911)

* Resume max retry time check for stale read retry with leader option

Signed-off-by: cfzjywxk <[email protected]>

* add cancel

Signed-off-by: cfzjywxk <[email protected]>

---------

Signed-off-by: cfzjywxk <[email protected]>

* request_source: remove default label (#890)

* request_source: remove default label

Signed-off-by: nolouch <[email protected]>

* add a function to set request source task type (#925)

* add a function to set request source task type

Signed-off-by: glorv <[email protected]>

* ci: update go version (#936)

* ci: update go version

Signed-off-by: crazycs520 <[email protected]>

* fix test

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>

* use tidb_kv_read_timeout as first kv request timeout (#919)

* support tidb_kv_read_timeout as first round kv request timeout

Signed-off-by: crazycs520 <[email protected]>

* fix ci

Signed-off-by: crazycs520 <[email protected]>

* fix ci

Signed-off-by: crazycs520 <[email protected]>

* fix ci

Signed-off-by: crazycs520 <[email protected]>

* fix ci

Signed-off-by: crazycs520 <[email protected]>

* fix ci

Signed-off-by: crazycs520 <[email protected]>

* update comment

Signed-off-by: crazycs520 <[email protected]>

* refine test

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>

* [pick] resource_control: bypass some internal urgent request (#938)

* resource_control: bypass some internal urgent request (#884)

Signed-off-by: nolouch <[email protected]>

* resourcecontrol: fix nil pointer (#900)

Signed-off-by: nolouch <[email protected]>

---------

Signed-off-by: nolouch <[email protected]>

---------

Signed-off-by: Chao Wang <[email protected]>
Signed-off-by: crazycs520 <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: nolouch <[email protected]>
Signed-off-by: Spade A <[email protected]>
Signed-off-by: guo-shaoge <[email protected]>
Signed-off-by: Jason Mo <[email protected]>
Signed-off-by: weedge <[email protected]>
Signed-off-by: you06 <[email protected]>
Signed-off-by: disksing <[email protected]>
Signed-off-by: husharp <[email protected]>
Signed-off-by: cfzjywxk <[email protected]>
Signed-off-by: glorv <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Co-authored-by: 王超 <[email protected]>
Co-authored-by: crazycs <[email protected]>
Co-authored-by: MyonKeminta <[email protected]>
Co-authored-by: MyonKeminta <[email protected]>
Co-authored-by: ShuNing <[email protected]>
Co-authored-by: Spade  A <[email protected]>
Co-authored-by: guo-shaoge <[email protected]>
Co-authored-by: disksing <[email protected]>
Co-authored-by: Hangjie Mo <[email protected]>
Co-authored-by: weedge <[email protected]>
Co-authored-by: you06 <[email protected]>
Co-authored-by: Hu# <[email protected]>
Co-authored-by: cfzjywxk <[email protected]>
Co-authored-by: glorv <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants