-
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
docs: RFC for better staleness read syntax. #22506
Closed
+63
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Proposal: Change timestamp bounds read syntax for read only transaction | ||
|
||
- Author(s): [Xiaoguang Sun](https://github.com/sunxiaoguang) | ||
- Last updated: 2021-01-24 | ||
- Discussion at: https://github.com/pingcap/tidb/issues/22505 | ||
|
||
## Abstract | ||
|
||
This proposal proposes new syntax to staleness read and deprecates existing timestamp bounds read SQL syntax which is over complicate. | ||
|
||
## Background | ||
|
||
Existing timestamp bound read SQL syntax is verbose and complicate. | ||
|
||
```sql | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND STRONG | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MAX STALENESS '00:00:10' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND EXACT STALENESS '00:00:05' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND READ TIMESTAMP '2019-11-04 00:00:00' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MIN READ TIMESTAMP '2019-11-04 00:00:00' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MIN TIMESTAMP '2019-11-04 00:00:00' | ||
``` | ||
|
||
Since timestamp bounds read feature is never implemented on TiDB, it is a good time to fix it with a better design and make it more ergonomics. | ||
|
||
## Proposal | ||
|
||
Make it clear that staleness read can be used only when transaction is read-only. If the transaction contains any writes an error will be returned. Therefore ```READ ONLY``` and ```TIMESTAMP BOUND``` are unnecessary and can be removed. The new statements will become shorter: | ||
|
||
```sql | ||
START TRANSACTION WITH MAX STALENESS '00:00:10' | ||
START TRANSACTION WITH EXACT STALENESS '00:00:05' | ||
START TRANSACTION WITH TIMESTAMP '2019-11-04 00:00:00' | ||
``` | ||
|
||
|
||
## Rationale | ||
|
||
```sql | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND STRONG | ||
``` | ||
|
||
These statements are equivalent to START TRANSACTION READ ONLY, therefore can be removed. | ||
|
||
```sql | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MAX STALENESS '00:00:10' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND EXACT STALENESS '00:00:05' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND READ TIMESTAMP '2019-11-04 00:00:00' | ||
``` | ||
|
||
The redundant words ```READ ONLY``` and ```TIMESTAMP BOUND``` as well as ```READ``` are removed for clarity. | ||
|
||
```sql | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MIN READ TIMESTAMP '2019-11-04 00:00:00' | ||
START TRANSACTION READ ONLY WITH TIMESTAMP BOUND MIN TIMESTAMP '2019-11-04 00:00:00' | ||
``` | ||
|
||
These statements are removed as they are obscured and useless. | ||
|
||
## Compatibility and Mirgration Plan | ||
Since existing syntax is never implemented on TiDB, it is unlikely to be used by anyone. We can simply remove current syntax and only support the new syntax. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
READ ONLY
warnings the txn must be a read-only transaction, rather than the user may do write operator in the transaction.