@@ -23,6 +23,23 @@ use tikv_client::RetryOptions;
2323use tikv_client:: TransactionClient ;
2424use tikv_client:: TransactionOptions ;
2525
26+ /// Mark a phase boundary in a long-running cleanup test.
27+ ///
28+ /// These tests occasionally stall in CI until nextest's 600s cap kills them (#516),
29+ /// and a killed test reports no elapsed timings — so the *entry* marker is the useful
30+ /// one: the last `phase >` line in the log names the step that never finished. The
31+ /// exit marker gives the duration when the test does complete, which is what tells a
32+ /// reader whether a step is merely slow or genuinely stuck.
33+ macro_rules! phase {
34+ ( $name: expr, $body: expr) => { {
35+ info!( "phase > {}" , $name) ;
36+ let __start = std:: time:: Instant :: now( ) ;
37+ let __out = $body;
38+ info!( "phase < {} in {:?}" , $name, __start. elapsed( ) ) ;
39+ __out
40+ } } ;
41+ }
42+
2643#[ tokio:: test]
2744#[ serial]
2845async fn txn_optimistic_heartbeat ( ) -> Result < ( ) > {
@@ -185,10 +202,16 @@ async fn txn_cleanup_async_commit_locks() -> Result<()> {
185202 Config :: default ( ) . with_default_keyspace ( ) ,
186203 )
187204 . await ?;
188- let keys = write_data ( & client, true , false ) . await ?;
205+ let keys = phase ! (
206+ "async/partial: write_data" ,
207+ write_data( & client, true , false ) . await ?
208+ ) ;
189209 // Wait for async commit to complete.
190210 let expected = keys. len ( ) * percent / 100 ;
191- let remaining = wait_for_locks_count ( & client, expected) . await ?;
211+ let remaining = phase ! (
212+ "async/partial: wait for locks to settle" ,
213+ wait_for_locks_count( & client, expected) . await ?
214+ ) ;
192215 assert_eq ! ( remaining, expected) ;
193216
194217 let safepoint = client. current_timestamp ( ) . await ?;
@@ -436,29 +459,41 @@ async fn txn_cleanup_2pc_locks() -> Result<()> {
436459 Config :: default ( ) . with_default_keyspace ( ) ,
437460 )
438461 . await ?;
439- let keys = write_data ( & client, false , true ) . await ?;
440- assert_eq ! ( count_locks( & client) . await ?, keys. len( ) ) ;
462+ let keys = phase ! (
463+ "2pc/no-commit: write_data" ,
464+ write_data( & client, false , true ) . await ?
465+ ) ;
466+ phase ! ( "2pc/no-commit: count locks" , {
467+ assert_eq!( count_locks( & client) . await ?, keys. len( ) ) ;
468+ } ) ;
441469
442470 let safepoint = client. current_timestamp ( ) . await ?;
443471 {
444472 let options = ResolveLocksOptions {
445473 async_commit_only : true , // Skip 2pc locks.
446474 ..Default :: default ( )
447475 } ;
448- client
449- . cleanup_locks ( full_range, & safepoint, options)
450- . await ?;
476+ phase ! ( "2pc/no-commit: cleanup_locks(async_commit_only)" , {
477+ client
478+ . cleanup_locks( full_range, & safepoint, options)
479+ . await ?;
480+ } ) ;
451481 assert_eq ! ( count_locks( & client) . await ?, keys. len( ) ) ;
452482 }
453483 let options = ResolveLocksOptions {
454484 async_commit_only : false ,
455485 ..Default :: default ( )
456486 } ;
457- client
458- . cleanup_locks ( full_range, & safepoint, options)
459- . await ?;
487+ phase ! ( "2pc/no-commit: cleanup_locks(all)" , {
488+ client
489+ . cleanup_locks( full_range, & safepoint, options)
490+ . await ?;
491+ } ) ;
460492
461- must_rollbacked ( & client, keys) . await ;
493+ phase ! (
494+ "2pc/no-commit: must_rollbacked" ,
495+ must_rollbacked( & client, keys) . await
496+ ) ;
462497 assert_eq ! ( count_locks( & client) . await ?, 0 ) ;
463498 }
464499
@@ -470,19 +505,29 @@ async fn txn_cleanup_2pc_locks() -> Result<()> {
470505 Config :: default ( ) . with_default_keyspace ( ) ,
471506 )
472507 . await ?;
473- let keys = write_data ( & client, false , false ) . await ?;
474- assert_eq ! ( wait_for_locks_count( & client, 0 ) . await ?, 0 ) ;
508+ let keys = phase ! (
509+ "2pc/all-committed: write_data" ,
510+ write_data( & client, false , false ) . await ?
511+ ) ;
512+ phase ! ( "2pc/all-committed: wait for locks to drain" , {
513+ assert_eq!( wait_for_locks_count( & client, 0 ) . await ?, 0 ) ;
514+ } ) ;
475515
476516 let safepoint = client. current_timestamp ( ) . await ?;
477517 let options = ResolveLocksOptions {
478518 async_commit_only : false ,
479519 ..Default :: default ( )
480520 } ;
481- client
482- . cleanup_locks ( full_range, & safepoint, options)
483- . await ?;
521+ phase ! ( "2pc/all-committed: cleanup_locks(all)" , {
522+ client
523+ . cleanup_locks( full_range, & safepoint, options)
524+ . await ?;
525+ } ) ;
484526
485- must_committed ( & client, keys) . await ;
527+ phase ! (
528+ "2pc/all-committed: must_committed" ,
529+ must_committed( & client, keys) . await
530+ ) ;
486531 assert_eq ! ( count_locks( & client) . await ?, 0 ) ;
487532 }
488533
0 commit comments