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

Wrong value of auto_increment after pause and resume for a tidb cloud cluster #46305

Closed
qiaoxinke opened this issue Aug 22, 2023 · 2 comments
Closed

Comments

@qiaoxinke
Copy link

qiaoxinke commented Aug 22, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. create a table with auto_increment pk
    create table t (id int auto_increment primary key, txt varchar(25)) auto_id_cache=1;
    insert into t(txt) values('aaa');
    mysql> show table t next_row_id;
    +---------+------------+-------------+--------------------+----------------+
    | DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ID_TYPE |
    +---------+------------+-------------+--------------------+----------------+
    | br_test | t | id | 1 | _TIDB_ROWID |
    | br_test | t | id | 2 | AUTO_INCREMENT |
    +---------+------------+-------------+--------------------+----------------+
    2 rows in set (0.18 sec)

  2. after pause& resume
    mysql> show table t next_row_id;
    +----------+---------------+-------------+--------------------+----------------+
    | DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ID_TYPE |
    +----------+---------------+-------------+--------------------+----------------+
    | br_test | t | _tidb_rowid | 1 | _TIDB_ROWID |
    | br_test | t | _tidb_rowid | 1 | AUTO_INCREMENT |<< wrong value
    +----------+---------------+-------------+--------------------+----------------+
    2 rows in set (0.20 sec)

  3. insert data
    mysql> insert into t(txt) values('aaa');
    Query OK, 1 row affected (0.19 sec)

-- row with id=2 inserted

  1. After insert , the auto_increment is updated to correct value. However we have no way to confirm the correct value at step 1 without insert.
    mysql> show table t next_row_id;
    +----------+---------------+-------------+--------------------+----------------+
    | DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ID_TYPE |
    +----------+---------------+-------------+--------------------+----------------+
    | br_test | t | _tidb_rowid | 1 | _TIDB_ROWID |
    | br_test | t | _tidb_rowid | 3 | AUTO_INCREMENT |<< correct value
    +----------+---------------+-------------+--------------------+----------------+
    2 rows in set (0.17 sec)

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

At step 2, show AUTO_INCREMENT as the correct value which is 2.

3. What did you see instead (Required)

1 was shown at step2.

4. What is your TiDB version? (Required)

v7.1.1

@qiaoxinke qiaoxinke added the type/bug This issue is a bug. label Aug 22, 2023
@lilyjazz
Copy link
Member

#46100

@tiancaiamao
Copy link
Contributor

duplicated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants