Does TiDB support shared locks?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb支持共享锁吗?

| username: CAICAI

Currently using TiDB version 5.4, I would like to ask which version of TiDB supports shared locks?

For example, a shared lock like this:

start transaction; 
select * from test where id = 1 lock in share mode;

Shared lock:
Allows different transactions to share locked reads, but does not allow other transactions to modify or add exclusive locks.
If there are modifications, they must wait for a transaction to complete before execution, which can easily lead to deadlocks.

I know TiDB supports select for update for exclusive locks, but I want to use MySQL-like shared locks. Does TiDB support this, and how can it be used?

| username: xfworld | Original post link

Shared locks are not supported, and there’s not much need for them.

TiDB supports MVCC (Multi-Version Concurrency Control), allowing you to read according to the specified version (multiple transactions can read).

If you need transaction control, a pessimistic lock is sufficient (only one transaction can update the new value).

| username: zhouzeru | Original post link

Not supported

| username: TiDBer_CEVsub | Original post link

Not supported