-
Notifications
You must be signed in to change notification settings - Fork 228
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
client: Cache tikv request in tidb client side #1098
Conversation
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
bfd7daa
to
680cc2d
Compare
Signed-off-by: bufferflies <[email protected]>
680cc2d
to
7f3cc02
Compare
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
9e7283f
to
e3a4cab
Compare
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
a74f4f9
to
5ebf055
Compare
Signed-off-by: bufferflies <[email protected]>
5ebf055
to
3602ee7
Compare
038d798
to
25fff22
Compare
if collect != nil { | ||
collect(b.idAlloc, e) | ||
} | ||
for (count < limit && b.entries.Len() > 0) || b.hasHighPriorityTask() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to disable the limit related code path if limit
is MaxInt64
value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's same if the limit is MaxInt64
. if the limit is set as MaxInt64
, the take operator will return all elements in the queues.
@crazycs520 PTAL |
Signed-off-by: bufferflies <[email protected]>
Signed-off-by: bufferflies <[email protected]>
9685f2d
to
94a0d9c
Compare
Signed-off-by: bufferflies <[email protected]>
metrics.TiKVNoAvailableConnectionCounter.Inc() | ||
|
||
// Please ensure the error is handled in region cache correctly. | ||
a.reqBuilder.cancel(errors.New("no available connections")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change these request are not canceled and retry sending them when new request arrives. So these request will be block if there is no new incoming requests, is it a proper behavior?
Another issue is that if the maxConcurrencyRequestLimit
is not very large, it is possible that the request builder can cache a lot of requests when the incoming requsets number are large, it may lead to issues such as OOM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change these request are not canceled and retry sending them when new request arrives. So these request will be block if there is no new incoming requests, is it a proper behavior?
yes, the request maybe block if there are any requests coming if the configuration is small. It will timeout and then retry it again. I will fixed it by notified mechanism.
Another issue is that if the maxConcurrencyRequestLimit is not very large, it is possible that the request builder can cache a lot of requests when the incoming requsets number are large, it may lead to issues such as OOM.
yes, it maybe happen in origin logic, the request object canbe gc after receiving response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the first issue, we may handle it in fetchAllPendingRequests
. That is, we can skip waiting for headEntry
when entries
is not empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It maybe cause busy loop if there's no one client that has sent token. I will optimaze it by using channel to notify the sender to sent requests again.
metrics.TiKVNoAvailableConnectionCounter.Inc() | ||
|
||
// Please ensure the error is handled in region cache correctly. | ||
a.reqBuilder.cancel(errors.New("no available connections")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the first issue, we may handle it in fetchAllPendingRequests
. That is, we can skip waiting for headEntry
when entries
is not empty.
internal/client/client_batch.go
Outdated
reasons = append(reasons, SendFailedReasonTryLockForSendFail) | ||
} | ||
} else { | ||
reasons = append(reasons, SendFailedReasonTryLockForSendFail) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reasons = append(reasons, SendFailedReasonTryLockForSendFail) | |
reasons = append(reasons, SendFailedReasonNoAvailableLimit) |
Signed-off-by: bufferflies <[email protected]>
9b3ea26
to
a01352e
Compare
Can we merge it? |
@@ -89,6 +90,9 @@ type TiKVClient struct { | |||
// TTLRefreshedTxnSize controls whether a transaction should update its TTL or not. | |||
TTLRefreshedTxnSize int64 `toml:"ttl-refreshed-txn-size" json:"ttl-refreshed-txn-size"` | |||
ResolveLockLiteThreshold uint64 `toml:"resolve-lock-lite-threshold" json:"resolve-lock-lite-threshold"` | |||
// MaxConcurrencyRequestLimit is the max concurrency number of request to be sent the tikv | |||
// 0 means auto adjust by feedback. | |||
MaxConcurrencyRequestLimit int64 `toml:"max-concurrency-request-limit" json:"max-concurrency-request-limit"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a public tidb configuration, should it be approved by the PM member according to the current process requirements?
|
Signed-off-by: bufferflies <[email protected]>
3ee8264
to
85f81ab
Compare
This reverts commit 824302a. Signed-off-by: crazycs520 <[email protected]>
This reverts commit 824302a. Signed-off-by: crazycs520 <[email protected]>
close #1099
Manual Test
rg1 is high priority, rg2 is medium priorit.
the connection of high priority always is 5,
the conncetion of medium priority is [5,20,50,100,200]
default
max-concurrency-request-limit =30
performance between master and this pr
The high priority sql run faster than the medium after set max-concurrency-request-limit =30
performance comapre