@@ -25,7 +25,7 @@ use tikv_client_proto::{kvrpcpb, pdpb::Timestamp};
2525/// and its mutations are readable for transactions with `start_ts` >= its `commit_ts`.
2626///
2727/// Mutations, or write operations made in a transaction are buffered locally and sent at the time of commit,
28- /// except for pessimisitc locking.
28+ /// except for pessimistic locking.
2929/// In pessimistic mode, all write operations or `xxx_for_update` operations will first acquire pessimistic locks in TiKV.
3030/// A lock exists until the transaction is committed (in the first phase of 2PC) or rolled back, or it exceeds its Time To Live (TTL).
3131///
@@ -126,8 +126,6 @@ impl Transaction {
126126 /// and the value is not cached in the local buffer.
127127 /// So normal `get`-like commands after `get_for_update` will not be influenced, they still read values at `start_ts`.
128128 ///
129- /// Different from `get`, this request does not distinguish between empty values and non-existent keys
130- /// , i.e. querying non-existent keys will result in empty values.
131129 ///
132130 /// It can only be used in pessimistic mode.
133131 ///
@@ -238,8 +236,7 @@ impl Transaction {
238236 /// and the value is not cached in the local buffer.
239237 /// So normal `get`-like commands after `batch_get_for_update` will not be influenced, they still read values at `start_ts`.
240238 ///
241- /// Different from `batch_get`, this request does not distinguish between empty values and non-existent keys
242- /// , i.e. querying non-existent keys will result in empty values.
239+ /// Non-existent entries will not appear in the result. The order of the keys is not retained in the result.
243240 ///
244241 /// It can only be used in pessimistic mode.
245242 ///
@@ -263,8 +260,6 @@ impl Transaction {
263260 /// txn.commit().await.unwrap();
264261 /// # });
265262 /// ```
266- // This is temporarily disabled because we cannot correctly match the keys and values.
267- // See `impl KvRequest for kvrpcpb::PessimisticLockRequest` for details.
268263 pub async fn batch_get_for_update (
269264 & mut self ,
270265 keys : impl IntoIterator < Item = impl Into < Key > > ,
@@ -607,10 +602,13 @@ impl Transaction {
607602 . await
608603 }
609604
610- /// Pessimistically lock the keys.
605+ /// Pessimistically lock the keys, and optionally retrieve corresponding values.
606+ /// If a key does not exist, the corresponding pair will not appear in the result.
607+ ///
608+ /// Once resolved it acquires locks on the keys in TiKV.
609+ /// A lock prevents other transactions from mutating the entry until it is released.
611610 ///
612- /// Once resolved it acquires a lock on the key in TiKV.
613- /// The lock prevents other transactions from mutating the entry until it is released.
611+ /// # Panics
614612 ///
615613 /// Only valid for pessimistic transactions, panics if called on an optimistic transaction.
616614 async fn pessimistic_lock (
0 commit comments