pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
37.03k stars 5.82k forks source link

Invalid memory address or nil pointer when upgrade to master version #56489

Open apollodafoni opened 20 hours ago

apollodafoni commented 20 hours ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
create database if not exists v1static;
set global tidb_analyze_version = 1;
set global tidb_partition_prune_mode = 'static';
set session tidb_enable_list_partition = 1;
create table rptcon (a bigint primary key, b varchar(20)) partition by range(a) (partition p0 values less than (10), partition p1 values less than (20), partition p2 values less than(30));
create table hptcon (a bigint primary key, b varchar(20)) partition by hash(a) partitions 3;
create table lptcon (a bigint primary key, b varchar(20)) partition by list(a) (partition p0 values in (1,2,3), partition p1 values in (14,16,18), partition p3 values in (20,25,27,29));
insert into rptcon values (1, 'a'), (2, 'b'), (3,'c'), (14, 'd'), (16, 'e'), (18, 'f'), (20, 'h'), (25, 'i'), (27, 'j'), (29, 'k');
insert into hptcon values (1, 'a'), (2, 'b'), (3,'c'), (14, 'd'), (16, 'e'), (18, 'f'), (20, 'h'), (25, 'i'), (27, 'j'), (29, 'k');
insert into lptcon values (1, 'a'), (2, 'b'), (3,'c'), (14, 'd'), (16, 'e'), (18, 'f'), (20, 'h'), (25, 'i'), (27, 'j'), (29, 'k');
drop stats rptcon;
drop stats hptcon;
drop stats lptcon;
analyze table rptcon  with 10 buckets;
analyze table hptcon  with 10 buckets;
analyze table lptcon  with 10 buckets;

before upgrade tidb version

Release Version: v8.0.0
Edition: Community
Git Commit Hash: 8ba1fa452b1ccdbfb85879ea94b9254aabba2916
Git Branch: HEAD
UTC Build Time: 2024-03-28 14:22:15
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv

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

use operator upgrade cluster to master version success

3. What did you see instead (Required)

start tidb-server ...
/tidb-server --store=tikv --advertise-address=cluster-tidb-1.cluster-tidb-peer.oltp-global-stats-update-tps-7632425-1-763.svc --host=0.0.0.0 --path=cluster-pd:2379 --config=/etc/tidb/tidb.toml

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x3bb741a]

goroutine 1 [running]:
github.com/pingcap/tidb/pkg/infoschema.(*infoschemaV2).TableByID(0xc002177d48, {0x0, 0x0}, 0x74)
    /workspace/source/tidb/pkg/infoschema/infoschema_v2.go:625 +0x19a
github.com/pingcap/tidb/pkg/session.rebuildAllPartitionValueMapAndSorted(0xc00164c788)
    /workspace/source/tidb/pkg/session/bootstrap.go:3578 +0x193
github.com/pingcap/tidb/pkg/session.bootstrapSessionImpl({0x6fec9e0, 0xc001057320}, 0x689c448)
    /workspace/source/tidb/pkg/session/session.go:3508 +0x5f9
github.com/pingcap/tidb/pkg/session.BootstrapSession(...)
    /workspace/source/tidb/pkg/session/session.go:3397
main.createStoreAndDomain({0x0?, 0x675fc28?})
    /workspace/source/tidb/cmd/tidb-server/main.go:414 +0x1b4
main.main()
    /workspace/source/tidb/cmd/tidb-server/main.go:320 +0x3c5

4. What is your TiDB version? (Required)

apollodafoni commented 20 hours ago

/assign @tiancaiamao /severity major

tiancaiamao commented 7 hours ago

OK, I can reproduce it follow above steps!