-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
What transaction isolation is supported? #2712
Comments
@vadimtk Thanks for your feedback! In your case, you can use "select for ... update" to prevent write skew. There is one thing you should notice. We also use optimistic lock to detect conflict at the commit stage. Unlike update/delete/insert, SelectForUpdate statement will not be retried automatically. The client will receive an error with message "can not retry select for update statement" and it should decide retry the statement or not. |
Hi, "select for .. update" helps in some cases, but now I am trying serializable and Anti-Dependency Cycles (G2): In TiDB Anti-Dependency Cycles (G2) is not prevented in serializable level. |
more on why G2 must be prevented you can find there cockroachdb/cockroach#10030 |
Hi @vadimtk , Strictly speaking, the isolation level we are providing should be Snapshot Isolation, you may also refer to the FAQ. In some cases, users can use SELECT ... FOR UPDATE to explicitly specify the rows that need to be locked to avoid write skew. If we want to support Serializable Isolation, we have to introduce table lock or range lock, which will affect the system's concurrent performance. In the future, we might provide configurable different isolation levels, allowing users to balance isolation level and performance according to their own situation. |
Then if you do not provide serializable, I recommend you should return an error on the following statement
|
Good idea. Thank you @vadimtk |
I am not familiar with your source code base, so I can't make a PR |
I think it would be better to print warning messages in console about ignoring the isolation level instead of fail this operation so that common applications won't break due to this change. |
Based on my tests and understanding, TiDB provides 2 isolation levels, the default isolation level is SI, can anyone help on below questions?
TiDB doesn't support the other 3 isolation level which supports by MySQL - read uncommitted, repeatable read, and serializable, but by using "set session transaction isolation level" statement you always get a "Query OK" msg, this is quite misleading, compared to warning msg, I suppose an error msg will be more actual. |
sometime |
I have the following proposal to help fix this issue:
The rationale being that providing a stronger level of consistency is less likely to produce issues and that some common ORMs do explicitly set (I will assign the issue to myself. I am happy to provide the patch.) |
@morgo I agree with you. |
I have a patch in #8625 which addresses this problem as described by my earlier comment. But having thought about the issue more, I have two suggested enhancements I would like feedback on:
|
Just a quick note, the final behavior is:
|
As TiDB declares strong consistency , I expect it should support SERIALIZABLE isolation level.
When I run test from "Hermitage" test suite
https://github.com/vadimtk/hermitage/blob/master/mysql-innodb.md
both Read Skew and Write Skew test fails in SERIALIZABLE level.
The example of queries, see:
MySQL "serializable" prevents Write Skew (G2-item)
The text was updated successfully, but these errors were encountered: