Skip to content

domain: lock error is not handled getting commit ts of schema diff key #48281

@cfzjywxk

Description

@cfzjywxk

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Running stale read with concurrent DDL statements.
The cause of this issue is that the mvccGetResp may contain Write information or Lock information when there's a perwrite lock on the key. In this situation, it's needed to resolve the lock to get the actual commit_ts of the schema version. Currently, it's not handled so even though the internal transaction has been committed the mvcc get may return nothing reading the schema diff key.

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

The stale read should use schema versions from schema cache.

3. What did you see instead (Required)

Sometimes the schema cache would be invalidated because of mvcc get error when getting commit ts of schema version.

Related debug logs

[2023/11/03 18:48:14.460 +08:00] [INFO] [ddl_worker.go:893] ["HandleDDLJobTable start commit ddl txn"] [schema-version=7542] [txn-start=445384882758352927]
[2023/11/03 18:48:14.468 +08:00] [INFO] [meta.go:398] ["get schema diff"] [v=7542] [diff="{\"version\":7542,\"type\":2,\"schema_id\":5704,\"table_id\":0,\"old_table_id\":0,\"old_schema_id\":0,\"affected_options\":null}"] []
[2023/11/03 18:48:14.468 +08:00] [INFO] [domain.go:272] ["get schema version mvcc meet lock"] [version=7542] [lock="start_ts:445384882758352927 primary:\"mDBs\\000\\000\\000\\000\\000\\372\\000\\000\\000\\000\\000\\000\\000hDB:5704\\000\\376\" short_value:\"{\\\"version\\\":7542,\\\"type\\\":2,\\\"schema_id\\\":5704,\\\"table_id\\\":0,\\\"old_table_id\\\":0,\\\"old_schema_id\\\":0,\\\"affected_options\\\":null}\" "]
[2023/11/03 18:48:14.468 +08:00] [WARN] [domain.go:196] ["failed to get schema version"] [error="There is no Write MVCC info for the schema version"] [version=7542] [startTS=445384882771460099]

4. What is your TiDB version? (Required)

v6.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.severity/majorsig/sql-infraSIG: SQL Infrasig/transactionSIG:Transactiontype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions