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

add a config to enable write statements to read on TiFlash #37515

Closed
gengliqi opened this issue Aug 31, 2022 · 0 comments · Fixed by #37516
Closed

add a config to enable write statements to read on TiFlash #37515

gengliqi opened this issue Aug 31, 2022 · 0 comments · Fixed by #37516
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@gengliqi
Copy link
Contributor

gengliqi commented Aug 31, 2022

Enhancement

TiFlash only supports the read-only statement due to a historical reason(or mistake?).
The worry in the past is that TiFlash can not support select ... for update because this SQL acquires some transaction locks and can not be done in TiFlash.
The behavior of the lock acquired by select ... for update in TiDB is a little bit complicated.
There are two kinds of cases:

  1. If the primary key or unique key can be used for the condition, then PointGet or BatchPointGet will be used. The lock will be acquired when getting the result. Note that the lock is acquired no matter whether the data exists or not. This case can only be handled in TiKV.
  2. Else coprocessor will be used. TiDB gets the row data and then sends lock requests to TiKV.

In case 1, it's very tricky. Fortunately, TiFlash doesn't support PointGet or BatchPointGet. It can only be sent to TiKV.
In case 2, there is no difference between TiKV and TiFlash that does the coprocessor work.

In conclusion, it's totally ok to enable write statements to read on TiFlash.

However, TiFlash only supports read-only statements for a long time, and the support of SQL mode is weak, there are many different behaviors when meeting warnings or errors. For example, in strict SQL mode, division by zero is a warning in read SQL while it's an error in write SQL. TiFlash doesn't distinguish the read SQL and write SQL for now.

Though we can not turn on this feature immediately, a config can be added for testing.

@gengliqi gengliqi added the type/enhancement The issue or PR belongs to an enhancement. label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant