@@ -10,7 +10,7 @@ use slog::info;
1010use std:: { collections:: HashSet , iter:: FromIterator , thread, time:: Duration } ;
1111use tikv_client:: {
1212 transaction:: { Client , HeartbeatOption , ResolveLocksOptions } ,
13- Backoff , Result , RetryOptions , TransactionClient , TransactionOptions ,
13+ Backoff , CheckLevel , Result , RetryOptions , TransactionClient , TransactionOptions ,
1414} ;
1515
1616#[ tokio:: test]
@@ -19,6 +19,9 @@ async fn txn_optimistic_heartbeat() -> Result<()> {
1919 init ( ) . await ?;
2020 let scenario = FailScenario :: setup ( ) ;
2121 fail:: cfg ( "after-prewrite" , "sleep(6000)" ) . unwrap ( ) ;
22+ defer ! { {
23+ fail:: cfg( "after-prewrite" , "off" ) . unwrap( ) ;
24+ } }
2225
2326 let key1 = "key1" . to_owned ( ) ;
2427 let key2 = "key2" . to_owned ( ) ;
@@ -27,7 +30,8 @@ async fn txn_optimistic_heartbeat() -> Result<()> {
2730 let mut heartbeat_txn = client
2831 . begin_with_options (
2932 TransactionOptions :: new_optimistic ( )
30- . heartbeat_option ( HeartbeatOption :: FixedTime ( Duration :: from_secs ( 1 ) ) ) ,
33+ . heartbeat_option ( HeartbeatOption :: FixedTime ( Duration :: from_secs ( 1 ) ) )
34+ . drop_check ( CheckLevel :: Warn ) ,
3135 )
3236 . await ?;
3337 heartbeat_txn. put ( key1. clone ( ) , "foo" ) . await . unwrap ( ) ;
@@ -36,7 +40,7 @@ async fn txn_optimistic_heartbeat() -> Result<()> {
3640 . begin_with_options (
3741 TransactionOptions :: new_optimistic ( )
3842 . heartbeat_option ( HeartbeatOption :: NoHeartbeat )
39- . drop_check ( tikv_client :: CheckLevel :: Warn ) ,
43+ . drop_check ( CheckLevel :: Warn ) ,
4044 )
4145 . await ?;
4246 txn_without_heartbeat
@@ -61,13 +65,15 @@ async fn txn_optimistic_heartbeat() -> Result<()> {
6165 TransactionOptions :: new_optimistic ( )
6266 . no_resolve_locks ( )
6367 . heartbeat_option ( HeartbeatOption :: NoHeartbeat )
64- . drop_check ( tikv_client :: CheckLevel :: Warn ) ,
68+ . drop_check ( CheckLevel :: Warn ) ,
6569 )
6670 . await ?;
6771 t3. put ( key1. clone ( ) , "gee" ) . await ?;
6872 assert ! ( t3. commit( ) . await . is_err( ) ) ;
6973
70- let mut t4 = client. begin_optimistic ( ) . await ?;
74+ let mut t4 = client
75+ . begin_with_options ( TransactionOptions :: new_optimistic ( ) . drop_check ( CheckLevel :: Warn ) )
76+ . await ?;
7177 t4. put ( key2. clone ( ) , "geee" ) . await ?;
7278 t4. commit ( ) . await ?;
7379
@@ -88,25 +94,14 @@ async fn txn_cleanup_locks_batch_size() -> Result<()> {
8894 let scenario = FailScenario :: setup ( ) ;
8995 let full_range = vec ! [ ] ..;
9096
91- let client = TransactionClient :: new ( pd_addrs ( ) , Some ( logger. clone ( ) ) ) . await ?;
92- // Clean all locks at the beginning to avoid other cases' side effect.
93- let safepoint = client. current_timestamp ( ) . await ?;
94- let options = ResolveLocksOptions {
95- async_commit_only : false ,
96- ..Default :: default ( )
97- } ;
98- client
99- . cleanup_locks ( & safepoint, full_range. clone ( ) , options)
100- . await
101- . unwrap ( ) ;
102-
10397 fail:: cfg ( "after-prewrite" , "return" ) . unwrap ( ) ;
10498 fail:: cfg ( "before-cleanup-locks" , "return" ) . unwrap ( ) ;
10599 defer ! { {
106100 fail:: cfg( "after-prewrite" , "off" ) . unwrap( ) ;
107101 fail:: cfg( "before-cleanup-locks" , "off" ) . unwrap( ) ;
108102 } }
109103
104+ let client = TransactionClient :: new ( pd_addrs ( ) , Some ( logger. clone ( ) ) ) . await ?;
110105 let keys = write_data ( & client, true , true ) . await ?;
111106 assert_eq ! ( count_locks( & client) . await ?, keys. len( ) ) ;
112107
@@ -376,7 +371,7 @@ async fn write_data(
376371 region_backoff : REGION_BACKOFF ,
377372 lock_backoff : OPTIMISTIC_BACKOFF ,
378373 } )
379- . drop_check ( tikv_client :: CheckLevel :: Warn ) ;
374+ . drop_check ( CheckLevel :: Warn ) ;
380375 if async_commit {
381376 options = options. use_async_commit ( ) ;
382377 }
0 commit comments