Skip to content

txn: support upgrade for share clause to for update #55022

@cfzjywxk

Description

@cfzjywxk

Feature Request

Is your feature request related to a problem? Please describe:

TiDB does not support Shared Lock. If we enable the compatibility by tidb_enable_noop_functions, TiDB can ignore the shared lock.

To make the for share statements acquire pessimistic locks as needed, a new mechanism is needed.

Describe the feature you'd like:

Introduce a new variable tidb_enable_shared_lock_upgrade to control whether the for share should acquire locks as the for update does.

tidb_enable_shared_lock_promotion
- Scope: GLOBAL | SESSION
- Persists to cluster: Yes
- Type: Boolean
- Default value: false
- Value options: true, false
- This variable indicate whether TiDB promotes Shared Lock to Exclusive Lock. When you set the variable to true, the statements SELECT ... FOR SHARE and SELECT ... LOCK IN SHARE MODE will be processed as SELECT ... FOR UPDATE. 

When it's enabled

Describe alternatives you've considered:

Implement the complete for share feature, it's quite complex and resource consuming.

Teachability, Documentation, Adoption, Migration Strategy:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions