lightning: nil pointer dereference when importing data without matching partition
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
importing data into partitioned table, but some of the data doesn't lie in any partition.
### 2. What did you expect to see? (Required)
lightning can success if the count of wrong data is smaller than configured `max-error`.
### 3. What did you see instead (Required)
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x89 pc=0x42d59a4]
goroutine 55431 [running]:
github.com/pingcap/tidb/pkg/sessionctx/variable.(*SessionVars).IsPessimisticReadConsistency(...)
/workspace/source/tidb/pkg/sessionctx/variable/session.go:2339
github.com/pingcap/tidb/pkg/planner/core.(*PlanBuilder).Init(...)
/workspace/source/tidb/pkg/planner/core/planbuilder.go:781
github.com/pingcap/tidb/pkg/planner/core.rewriteAstExpr(...)
/workspace/source/tidb/pkg/planner/core/expression_rewriter.go:72
github.com/pingcap/tidb/pkg/expression.RewriteSimpleExprWithTableInfo(...)
/workspace/source/tidb/pkg/expression/simple_rewriter.go:75
github.com/pingcap/tidb/pkg/expression.ParseSimpleExprWithTableInfo(...)
/workspace/source/tidb/pkg/expression/simple_rewriter.go:54
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).locateRangePartition(...)
/workspace/source/tidb/pkg/table/tables/partition.go:1430
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).locatePartitionCommon(...)
/workspace/source/tidb/pkg/table/tables/partition.go:1024
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).locatePartition(...)
/workspace/source/tidb/pkg/table/tables/partition.go:1313
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).AddRecord(...)
/workspace/source/tidb/pkg/table/tables/partition.go:1596
github.com/pingcap/tidb/br/pkg/lightning/backend/kv.(*BaseKVEncoder).Record2KV(...)
/workspace/source/tidb/br/pkg/lightning/backend/kv/base.go:193
github.com/pingcap/tidb/br/pkg/lightning/backend/kv.(*tidbEncoder).Encode(...)
/workspace/source/tidb/br/pkg/lightning/backend/kv/sql2kv.go:242
github.com/pingcap/tidb/br/pkg/lightning/importer.(*dupDetector).addKeysByChunk(...)
/workspace/source/tidb/br/pkg/lightning/importer/dup_detect.go:324
github.com/pingcap/tidb/br/pkg/lightning/importer.(*dupDetector).addKeys.func1()
/workspace/source/tidb/br/pkg/lightning/importer/dup_detect.go:230
golang.org/x/sync/errgroup.(*Group).Go.func1()
/root/go/pkg/mod/golang.org/x/sync@v0.5.0/errgroup/errgroup.go:75
created by golang.org/x/sync/errgroup.(*Group).Go
/root/go/pkg/mod/golang.org/x/sync@v0.5.0/errgroup/errgroup.go:72
```
### 4. What is your TiDB version? (Required)
7.5. Only 7.5 and 8.1 are affected.
Contributor guide
Assessment
This issue has not been assessed yet.