You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The coprocessor cache caches a response for each request on the TiDB side. If two coprocessor requests are equivalent, the second request may skip being processed on the TiKV side. However, the request is still sent to TiKV, because TiKV needs to judge whether the cached response is still valid.
For stale read and history read, the requested snapshot is older than the current. What concerns us is whether the coprocessor cache is still always valid for these kinds of reading.
Analysis
The coprocessor cache is hit when (see copIteratorWorker.handleTaskOnce and copIteratorWorker.handleCopResponse):
The number of requested ranges, the data size of the response, and the processing time of the request are all within the thresholds. That is, the response deserves to be cached.
The region ID of the request and the cached response equals. That is, the region doesn't split or merge after it's cached.
The start TS of the cached response is not greater than the start TS of the request. That is, the cached response won't be too new for the request.
The applied index of this region doesn't change between the start TS of the cached response and the request. That is, the region is untouched after the response is cached. This is judged on the TiKV side.
Through the last two conditions, we can infer that as long as the start TS of the transactions of stale read and history read is set correctly, the cached response will be valid.
Conclusion
We don't need to change anything.
The text was updated successfully, but these errors were encountered:
Background
This is a subtask of #21094.
The coprocessor cache caches a response for each request on the TiDB side. If two coprocessor requests are equivalent, the second request may skip being processed on the TiKV side. However, the request is still sent to TiKV, because TiKV needs to judge whether the cached response is still valid.
For stale read and history read, the requested snapshot is older than the current. What concerns us is whether the coprocessor cache is still always valid for these kinds of reading.
Analysis
The coprocessor cache is hit when (see
copIteratorWorker.handleTaskOnce
andcopIteratorWorker.handleCopResponse
):Through the last two conditions, we can infer that as long as the start TS of the transactions of stale read and history read is set correctly, the cached response will be valid.
Conclusion
We don't need to change anything.
The text was updated successfully, but these errors were encountered: