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
pessimistic-txn: solve non-pessimistic-lock conflict #4801
Changes from 11 commits
ad2c0b7
928015e
9dc44b4
0c97e0a
5881075
0a88057
8ffe875
e5895b6
b7d935c
5fef132
bf054bc
cc0490a
9a242fc
cdd9a21
1666be9
1d4b0ff
4d5e7fb
7d2f655
14f6be9
a3e9dd5
098241a
ac1b250
f28cac1
b095cc6
e3459f0
b7c1a74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ pub type Callback<T> = Box<dyn FnOnce(Result<T>) + Send>; | |
// Short value max len must <= 255. | ||
pub const SHORT_VALUE_MAX_LEN: usize = 64; | ||
pub const SHORT_VALUE_PREFIX: u8 = b'v'; | ||
pub const PESSIMISTIC_TXN: u8 = b'p'; | ||
pub const FOR_UPDATE_TS_PREFIX: u8 = b'f'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's not a good idea to change the prefix .. we will have two different kinds of prefix between versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if the prefix is the same, different versions won't be compatible because the old version doesn't record There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is ok since this feature is in developing. |
||
pub const TXN_SIZE_PREFIX: u8 = b't'; | ||
|
||
use engine::{CfName, ALL_CFS, CF_DEFAULT, CF_LOCK, CF_WRITE, DATA_CFS}; | ||
|
@@ -99,7 +99,6 @@ pub enum Command { | |
keys: Vec<(Key, bool)>, | ||
primary: Vec<u8>, | ||
start_ts: u64, | ||
for_update_ts: u64, | ||
options: Options, | ||
}, | ||
Commit { | ||
|
@@ -176,14 +175,12 @@ impl Display for Command { | |
ref ctx, | ||
ref keys, | ||
start_ts, | ||
for_update_ts, | ||
.. | ||
} => write!( | ||
f, | ||
"kv::command::acquirepessimisticlock keys({}) @ {},{} | {:?}", | ||
"kv::command::acquirepessimisticlock keys({}) @ {} | {:?}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to display for_update_ts, it is useful for debugging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
keys.len(), | ||
start_ts, | ||
for_update_ts, | ||
ctx | ||
), | ||
Command::Commit { | ||
|
@@ -436,6 +433,7 @@ pub struct Options { | |
pub key_only: bool, | ||
pub reverse_scan: bool, | ||
pub is_first_lock: bool, | ||
pub for_update_ts: u64, | ||
pub is_pessimistic_lock: Vec<bool>, | ||
// How many keys this transaction involved. | ||
pub txn_size: u64, | ||
|
@@ -449,6 +447,7 @@ impl Options { | |
key_only, | ||
reverse_scan: false, | ||
is_first_lock: false, | ||
for_update_ts: 0, | ||
is_pessimistic_lock: vec![], | ||
txn_size: 0, | ||
} | ||
|
@@ -938,7 +937,6 @@ impl<E: Engine> Storage<E> { | |
keys: Vec<(Key, bool)>, | ||
primary: Vec<u8>, | ||
start_ts: u64, | ||
for_update_ts: u64, | ||
options: Options, | ||
callback: Callback<Vec<Result<()>>>, | ||
) -> Result<()> { | ||
|
@@ -959,7 +957,6 @@ impl<E: Engine> Storage<E> { | |
keys, | ||
primary, | ||
start_ts, | ||
for_update_ts, | ||
options, | ||
}; | ||
self.schedule(cmd, StorageCb::Booleans(callback))?; | ||
|
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.
Why we need
for_update_ts
in prewrite, seems we already have it byacquire_pessimistic_lock
?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.
By the way, why the
for_update_ts
is the same for all key in theprewrite
command?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.
for_update_ts
is used to resolve non-pessimistic-lock conflict.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.
TiDB
uses the lastfor_update_ts
as prewrite's.