Closed sre-bot closed 5 months ago
PTAL @AilinKid
hi~ there is a interesting logic here TiDB has dynamic cache size computation, according to the last cache consume-time. When table created, the default last allocation time is now() although there is no cache allocated before. Once you insert for the first time, the cache finds itself size was 0, so the next cache size will recomputed with formula below:
func NextStep(curStep int64, consumeDur time.Duration) int64 {
failpoint.Inject("mockAutoIDChange", func(val failpoint.Value) {
if val.(bool) {
failpoint.Return(step)
}
})
consumeRate := defaultConsumeTime.Seconds() / consumeDur.Seconds()
res := int64(float64(curStep) * consumeRate)
if res < minStep {
return minStep
} else if res > maxStep {
return maxStep
}
return res
}
So if you insert after the table created for a while, the next cache size will be 30000, otherwise if you put the create table + insert SQL into server simutaniously, the time interval will be short, so you will get 200000 instead.
The issue has not been updated for too long, so I will close it. If there are any updates you can reopen it.
Bug Hunter issue tidb-challenge-program/bug-hunting-issue#66
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. What did you do?
This is a regression:
2. What did you expect to see?
TiDB 2.1.2 (the version I had on hand):
3. What did you see instead?
TiDB 4.0:
Because integers default to signed, that is 1/1000th of the keyspace consumed. It looks like the next restart only consumes
30000
values, which is better. But I haven't tested with multiple tidb-servers:4. What version of TiDB are you using? (
tidb-server -V
or runselect tidb_version();
on TiDB)