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

runtime error: makeslice: cap out of range #23625

Closed
aytrack opened this issue Mar 29, 2021 · 2 comments · Fixed by #23890
Closed

runtime error: makeslice: cap out of range #23625

aytrack opened this issue Mar 29, 2021 · 2 comments · Fixed by #23890
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Mar 29, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

source uk_multi_col_11220.txt

select * from UK_MULTI_COL_11220 where col3 between "8499-1-23 2:14:38" and "9961-7-23 18:35:26" AND col1 < 6448082973738038426;

Sorry about that I can't reproduce this issue after the TiDB cluster was redeployed. The original cluster was destroyed because the server system disk was broken, and these two clusters using the same config. But I think it's an issue worth investigating.

#  old cluster
tidb.log:[2021/03/27 18:13:19.873 +08:00] [INFO] [printer.go:33] ["Welcome to TiDB."] ["Release Version"=v4.0.0-beta.2-2477-g149440854-dirty] [Edition=Community] ["Git Commit Hash"=149440854e539ba5e674109f96af13cf9e34fe7f] ["Git Branch"=master] ["UTC Build Time"="2021-03-26 13:48:42"] [GoVersion=go1.13] ["Race Enabled"=false] ["Check Table Before Drop"=false] ["TiKV Min Version"=v3.0.0-60965b006877ca7234adaced7890d7b029ed1306]

# new cluster
tidb.log:[2021/03/28 16:12:18.554 +08:00] [INFO] [printer.go:33] ["Welcome to TiDB."] ["Release Version"=v4.0.0-beta.2-2477-g149440854-dirty] [Edition=Community] ["Git Commit Hash"=149440854e539ba5e674109f96af13cf9e34fe7f] ["Git Branch"=master] ["UTC Build Time"="2021-03-26 13:48:42"] [GoVersion=go1.13] ["Race Enabled"=false] ["Check Table Before Drop"=false] ["TiKV Min Version"=v3.0.0-60965b006877ca7234adaced7890d7b029ed1306]
# old
tidb.log:[2021/03/27 18:13:19.873 +08:00] [INFO] [printer.go:47] ["loaded config"] [config="{\"host\":\"0.0.0.0\",\"advertise-address\":\"172.16.5.40\",\"port\":4010,\"cors\":\"\",\"store\":\"tikv\",\"path\":\"172.16.4.212:2379\",\"socket\":\"\",\"lease\":\"45s\",\"run-ddl\":true,\"split-table\":true,\"token-limit\":1000,\"oom-use-tmp-storage\":true,\"tmp-storage-path\":\"/tmp/1001_tidb/MC4wLjAuMDo0MDEwLzAuMC4wLjA6MTAxODA=/tmp-storage\",\"oom-action\":\"cancel\",\"mem-quota-query\":1073741824,\"tmp-storage-quota\":-1,\"enable-streaming\":false,\"enable-batch-dml\":false,\"lower-case-table-names\":2,\"server-version\":\"\",\"log\":{\"level\":\"info\",\"format\":\"text\",\"disable-timestamp\":null,\"enable-timestamp\":null,\"disable-error-stack\":null,\"enable-error-stack\":null,\"file\":{\"filename\":\"/home/tidb/comptest/tidb2/log/tidb.log\",\"max-size\":300,\"max-days\":0,\"max-backups\":0},\"enable-slow-log\":true,\"slow-query-file\":\"log/tidb_slow_query.log\",\"slow-threshold\":300,\"expensive-threshold\":10000,\"query-log-max-len\":4096,\"record-plan-in-slow-log\":1},\"security\":{\"skip-grant-table\":false,\"ssl-ca\":\"\",\"ssl-cert\":\"\",\"ssl-key\":\"\",\"require-secure-transport\":false,\"cluster-ssl-ca\":\"\",\"cluster-ssl-cert\":\"\",\"cluster-ssl-key\":\"\",\"cluster-verify-cn\":null,\"spilled-file-encryption-method\":\"plaintext\"},\"status\":{\"status-host\":\"0.0.0.0\",\"metrics-addr\":\"\",\"status-port\":10180,\"metrics-interval\":15,\"report-status\":true,\"record-db-qps\":false},\"performance\":{\"max-procs\":0,\"max-memory\":0,\"server-memory-quota\":0,\"memory-usage-alarm-ratio\":0.8,\"stats-lease\":\"3s\",\"stmt-count-limit\":5000,\"feedback-probability\":0,\"query-feedback-limit\":512,\"pseudo-estimate-ratio\":0.8,\"force-priority\":\"NO_PRIORITY\",\"bind-info-lease\":\"3s\",\"txn-entry-size-limit\":6291456,\"txn-total-size-limit\":104857600,\"tcp-keep-alive\":true,\"tcp-no-delay\":true,\"cross-join\":true,\"run-auto-analyze\":true,\"agg-push-down-join\":false,\"committer-concurrency\":16,\"max-txn-ttl\":3600000,\"mem-profile-interval\":\"1m\",\"index-usage-sync-lease\":\"0s\",\"gogc\":100},\"prepared-plan-cache\":{\"enabled\":false,\"capacity\":100,\"memory-guard-ratio\":0.1},\"opentracing\":{\"enable\":false,\"rpc-metrics\":false,\"sampler\":{\"type\":\"const\",\"param\":1,\"sampling-server-url\":\"\",\"max-operations\":0,\"sampling-refresh-interval\":0},\"reporter\":{\"queue-size\":0,\"buffer-flush-interval\":0,\"log-spans\":false,\"local-agent-host-port\":\"\"}},\"proxy-protocol\":{\"networks\":\"\",\"header-timeout\":5},\"pd-client\":{\"pd-server-timeout\":3},\"tikv-client\":{\"grpc-connection-count\":4,\"grpc-keepalive-time\":10,\"grpc-keepalive-timeout\":3,\"grpc-compression-type\":\"none\",\"commit-timeout\":\"41s\",\"async-commit\":{\"keys-limit\":256,\"total-key-size-limit\":4096,\"safe-window\":2000000000,\"allowed-clock-drift\":500000000},\"max-batch-size\":128,\"overload-threshold\":200,\"max-batch-wait-time\":0,\"batch-wait-size\":8,\"enable-chunk-rpc\":true,\"region-cache-ttl\":600,\"store-limit\":0,\"store-liveness-timeout\":\"1s\",\"copr-cache\":{\"capacity-mb\":1000},\"ttl-refreshed-txn-size\":33554432},\"binlog\":{\"enable\":false,\"ignore-error\":false,\"write-timeout\":\"15s\",\"binlog-socket\":\"\",\"strategy\":\"range\"},\"compatible-kill-query\":false,\"plugin\":{\"dir\":\"\",\"load\":\"\"},\"pessimistic-txn\":{\"max-retry-count\":256},\"check-mb4-value-in-utf8\":true,\"max-index-length\":3072,\"index-limit\":64,\"table-column-count-limit\":1017,\"graceful-wait-before-shutdown\":0,\"alter-primary-key\":false,\"treat-old-version-utf8-as-utf8mb4\":true,\"enable-table-lock\":false,\"delay-clean-table-lock\":0,\"split-region-max-num\":1000,\"stmt-summary\":{\"enable\":true,\"enable-internal-query\":false,\"max-stmt-count\":200,\"max-sql-length\":4096,\"refresh-interval\":1800,\"history-size\":24},\"repair-mode\":false,\"repair-table-list\":[],\"isolation-read\":{\"engines\":[\"tikv\",\"tiflash\",\"tidb\"]},\"max-server-connections\":0,\"new_collations_enabled_on_first_bootstrap\":true,\"experimental\":{\"allow-expression-index\":true},\"enable-collect-execution-info\":true,\"skip-register-to-dashboard\":false,\"enable-telemetry\":true,\"labels\":{},\"enable-global-index\":false,\"deprecate-integer-display-length\":false,\"enable-enum-length-limit\":true,\"stores-refresh-interval\":60,\"enable-tcp4-only\":false,\"enable-forwarding\":false}"]

# new
tidb.log:[2021/03/28 16:12:18.555 +08:00] [INFO] [printer.go:47] ["loaded config"] [config="{\"host\":\"0.0.0.0\",\"advertise-address\":\"172.16.5.40\",\"port\":4010,\"cors\":\"\",\"store\":\"tikv\",\"path\":\"172.16.4.55:2379\",\"socket\":\"\",\"lease\":\"45s\",\"run-ddl\":true,\"split-table\":true,\"token-limit\":1000,\"oom-use-tmp-storage\":true,\"tmp-storage-path\":\"/tmp/1001_tidb/MC4wLjAuMDo0MDEwLzAuMC4wLjA6MTAxODA=/tmp-storage\",\"oom-action\":\"cancel\",\"mem-quota-query\":1073741824,\"tmp-storage-quota\":-1,\"enable-streaming\":false,\"enable-batch-dml\":false,\"lower-case-table-names\":2,\"server-version\":\"\",\"log\":{\"level\":\"info\",\"format\":\"text\",\"disable-timestamp\":null,\"enable-timestamp\":null,\"disable-error-stack\":null,\"enable-error-stack\":null,\"file\":{\"filename\":\"/home/tidb/comptest/tidb2/log/tidb.log\",\"max-size\":300,\"max-days\":0,\"max-backups\":0},\"enable-slow-log\":true,\"slow-query-file\":\"log/tidb_slow_query.log\",\"slow-threshold\":300,\"expensive-threshold\":10000,\"query-log-max-len\":4096,\"record-plan-in-slow-log\":1},\"security\":{\"skip-grant-table\":false,\"ssl-ca\":\"\",\"ssl-cert\":\"\",\"ssl-key\":\"\",\"require-secure-transport\":false,\"cluster-ssl-ca\":\"\",\"cluster-ssl-cert\":\"\",\"cluster-ssl-key\":\"\",\"cluster-verify-cn\":null,\"spilled-file-encryption-method\":\"plaintext\"},\"status\":{\"status-host\":\"0.0.0.0\",\"metrics-addr\":\"\",\"status-port\":10180,\"metrics-interval\":15,\"report-status\":true,\"record-db-qps\":false},\"performance\":{\"max-procs\":0,\"max-memory\":0,\"server-memory-quota\":0,\"memory-usage-alarm-ratio\":0.8,\"stats-lease\":\"3s\",\"stmt-count-limit\":5000,\"feedback-probability\":0,\"query-feedback-limit\":512,\"pseudo-estimate-ratio\":0.8,\"force-priority\":\"NO_PRIORITY\",\"bind-info-lease\":\"3s\",\"txn-entry-size-limit\":6291456,\"txn-total-size-limit\":104857600,\"tcp-keep-alive\":true,\"tcp-no-delay\":true,\"cross-join\":true,\"run-auto-analyze\":true,\"agg-push-down-join\":false,\"committer-concurrency\":16,\"max-txn-ttl\":3600000,\"mem-profile-interval\":\"1m\",\"index-usage-sync-lease\":\"0s\",\"gogc\":100},\"prepared-plan-cache\":{\"enabled\":false,\"capacity\":100,\"memory-guard-ratio\":0.1},\"opentracing\":{\"enable\":false,\"rpc-metrics\":false,\"sampler\":{\"type\":\"const\",\"param\":1,\"sampling-server-url\":\"\",\"max-operations\":0,\"sampling-refresh-interval\":0},\"reporter\":{\"queue-size\":0,\"buffer-flush-interval\":0,\"log-spans\":false,\"local-agent-host-port\":\"\"}},\"proxy-protocol\":{\"networks\":\"\",\"header-timeout\":5},\"pd-client\":{\"pd-server-timeout\":3},\"tikv-client\":{\"grpc-connection-count\":4,\"grpc-keepalive-time\":10,\"grpc-keepalive-timeout\":3,\"grpc-compression-type\":\"none\",\"commit-timeout\":\"41s\",\"async-commit\":{\"keys-limit\":256,\"total-key-size-limit\":4096,\"safe-window\":2000000000,\"allowed-clock-drift\":500000000},\"max-batch-size\":128,\"overload-threshold\":200,\"max-batch-wait-time\":0,\"batch-wait-size\":8,\"enable-chunk-rpc\":true,\"region-cache-ttl\":600,\"store-limit\":0,\"store-liveness-timeout\":\"1s\",\"copr-cache\":{\"capacity-mb\":1000},\"ttl-refreshed-txn-size\":33554432},\"binlog\":{\"enable\":false,\"ignore-error\":false,\"write-timeout\":\"15s\",\"binlog-socket\":\"\",\"strategy\":\"range\"},\"compatible-kill-query\":false,\"plugin\":{\"dir\":\"\",\"load\":\"\"},\"pessimistic-txn\":{\"max-retry-count\":256},\"check-mb4-value-in-utf8\":true,\"max-index-length\":3072,\"index-limit\":64,\"table-column-count-limit\":1017,\"graceful-wait-before-shutdown\":0,\"alter-primary-key\":false,\"treat-old-version-utf8-as-utf8mb4\":true,\"enable-table-lock\":false,\"delay-clean-table-lock\":0,\"split-region-max-num\":1000,\"stmt-summary\":{\"enable\":true,\"enable-internal-query\":false,\"max-stmt-count\":200,\"max-sql-length\":4096,\"refresh-interval\":1800,\"history-size\":24},\"repair-mode\":false,\"repair-table-list\":[],\"isolation-read\":{\"engines\":[\"tikv\",\"tiflash\",\"tidb\"]},\"max-server-connections\":0,\"new_collations_enabled_on_first_bootstrap\":true,\"experimental\":{\"allow-expression-index\":true},\"enable-collect-execution-info\":true,\"skip-register-to-dashboard\":false,\"enable-telemetry\":true,\"labels\":{},\"enable-global-index\":false,\"deprecate-integer-display-length\":false,\"enable-enum-length-limit\":true,\"stores-refresh-interval\":60,\"enable-tcp4-only\":false,\"enable-forwarding\":false}"]

2. What did you expect to see? (Required)

TiDB running without panic and got correct results

3. What did you see instead (Required)

tidb panic

tidb.log:[2021/03/27 23:04:43.591 +08:00] [ERROR] [conn.go:736] ["connection running loop panic"] [conn=3439] [lastSQL="select * from UK_MULTI_COL_11220 where col3 between \"8499-1-23 2:14:38\" and \"9961-7-23 18:35:26\" AND col1 < 6448082973738038426;"] [err="runtime error: makeslice: cap out of range"] [stack="goroutine 150410140 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x4000340, 0xc05adda270, 0xc0823c9600)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:734 +0xee\npanic(0x3594e40, 0x3f5f2b0)\n\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\ngithub.com/pingcap/tidb/statistics.enumRangeValues(0xd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3961100, 0xc082d8b8a8, 0xd, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/statistics/scalar.go:279 +0xc8f\ngithub.com/pingcap/tidb/statistics.(*Column).GetColumnRowCount(0xc03e3dd320, 0xc0583bdb00, 0xc0598a0210, 0x1, 0x1, 0x0, 0x0, 0xc0598a0218, 0x3, 0x1)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/statistics/histogram.go:1067 +0x383\ngithub.com/pingcap/tidb/statistics.(*HistColl).GetRowCountByColumnRanges(0xc0598b0800, 0xc0583bdb00, 0x3, 0xc0598a0210, 0x1, 0x1, 0x0, 0x1, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/statistics/table.go:322 +0xc7\ngithub.com/pingcap/tidb/statistics.(*HistColl).Selectivity(0xc0598b0800, 0x4058e20, 0xc0846c3600, 0xc0598b07c0, 0x3, 0x4, 0xc079d550e0, 0x1, 0x3, 0x216aff0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/statistics/selectivity.go:233 +0x713\ngithub.com/pingcap/tidb/planner/core.(*DataSource).deriveStatsByFilter(0xc059066780, 0xc0598b07c0, 0x3, 0x4, 0xc079d550e0, 0x1, 0x3, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/stats.go:240 +0xae\ngithub.com/pingcap/tidb/planner/core.(*DataSource).DeriveStats(0xc059066780, 0x5f85e80, 0x0, 0x0, 0xc031622500, 0x5f85e80, 0x0, 0x0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/stats.go:277 +0x1f3\ngithub.com/pingcap/tidb/planner/core.(*baseLogicalPlan).recursiveDeriveStats(0xc0590667a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/stats.go:125 +0x2fc\ngithub.com/pingcap/tidb/planner/core.(*baseLogicalPlan).recursiveDeriveStats(0xc0591a4f00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/stats.go:118 +0x1a1\ngithub.com/pingcap/tidb/planner/core.physicalOptimize(0x4054e20, 0xc0591a4ee0, 0xc082d8b858, 0x4054e20, 0xc0591a4ee0, 0x4054e20, 0xc0591a4ee0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:212 +0x5d\ngithub.com/pingcap/tidb/planner/core.DoOptimize(0x4000340, 0xc05996aa80, 0x4058e20, 0xc0846c3600, 0xa2, 0x4054e20, 0xc0591a4ee0, 0x0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:143 +0x13a\ngithub.com/pingcap/tidb/planner.optimize(0x4000340, 0xc05996aa80, 0x4058e20, 0xc0846c3600, 0x401ed80, 0xc0820c5a00, 0x404b560, 0xc0348605f0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/optimize.go:289 +0x66c\ngithub.com/pingcap/tidb/planner.Optimize(0x4000340, 0xc05996aa80, 0x4058e20, 0xc0846c3600, 0x401ed80, 0xc0820c5a00, 0x404b560, 0xc0348605f0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/optimize.go:125 +0x494\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile(0xc0154dcd68, 0x4000340, 0xc05996aa80, 0x4026be0, 0xc0820c5a00, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/compiler.go:62 +0x294\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc0846c3600, 0x4000340, 0xc05996aa80, 0x4026be0, 0xc0820c5a00, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/session/session.go:1409 +0x2c4\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc05adda690, 0x4000340, 0xc05996aa80, 0x4026be0, 0xc0820c5a00, 0xc086543a40, 0x4000340, 0xc05996aa80, 0xc0154dd138)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/server/driver_tidb.go:218 +0x68\ngithub.com/pingcap/tidb/server.("]

4. What is your TiDB version? (Required)

mysql root@172.16.5.40:hchwang> select tidb_version()\G
***************************[ 1. row ]***************************
tidb_version() | Release Version: v4.0.0-beta.2-2477-g149440854-dirty
Edition: Community
Git Commit Hash: 149440854e539ba5e674109f96af13cf9e34fe7f
Git Branch: master
UTC Build Time: 2021-03-26 13:48:42
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

@tiancaiamao tiancaiamao added the affects-4.0 This bug affects 4.0.x versions. label Nov 22, 2021
@tiancaiamao
Copy link
Contributor

5.0 and newer versions are fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants