pingcap / pingcap/tidb

Lightning: AUTO-INCR Value Cannot Skip Those pre-set Values on Local Backend

Open
#34,565 3 comments 0 reactions 1 assignee Claimed by @dsdashun View on GitHub
component/lightning severity/moderate type/bug
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)

The source schema is like this:
CREATE TABLE test_tbl (
id bigint PRIMARY KEY AUTO_INCREMENT,
c char(40) NOT NULL DEFAULT '');

The input data is a SQL file. Some INSERT records uses pre-occupied value for auto-increment column

INSERT INTO test_tbl (id, c) VALUES
(2, 'normal_pk_02');
INSERT INTO test_tbl (id, c) VALUES
(NULL, 'null_pk_0x');

Then use local backend to import the data

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

The importing should succeed without problems. The expected table data:
2, "normal_pk_02"
3, "null_pk_0x"

### 3. What did you see instead (Required)

The importing failed on doing checksum:

Error: [Lighting:Restore:ErrChecksumMismatch]checksum mismatched remote vs local => (checksum: 2865254778919521267 vs 16530462478313441880) (total_kvs: 1 vs 2) (total_bytes:40 vs 78)
tidb lightning encountered error: [Lighting:Restore:ErrChecksumMismatch]checksum mismatched remote vs local => (checksum: 2865254778919521267 vs 16530462478313441880) (total_kvs: 1 vs 2) (total_bytes:40 vs 78)

The table data:
2, 'normal_pk_02'

It seems that when second row try to convert the SQL into binary row data, it uses its row ID (2) as the id column value. However, this value has already been used by the first row.

### 4. What is your TiDB version? (Required)
Latest master build

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.