Skip to content

Commit b5213b7

Browse files
authored
Merge branch 'master' into shared-locks
2 parents 6e07351 + 2aa94c1 commit b5213b7

2 files changed

Lines changed: 74 additions & 18 deletions

File tree

tests/common/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ async fn ensure_region_split(
113113

114114
info!("splitting regions...");
115115
let start_time = std::time::Instant::now();
116+
let mut observed_regions;
116117
loop {
117-
if ctl::get_region_count().await? as u32 >= region_count {
118+
observed_regions = ctl::get_region_count().await? as u32;
119+
if observed_regions >= region_count {
118120
break;
119121
}
120122
if start_time.elapsed() > REGION_SPLIT_TIME_LIMIT {
@@ -123,6 +125,15 @@ async fn ensure_region_split(
123125
}
124126
sleep(Duration::from_millis(200)).await;
125127
}
128+
// Setup cost is charged to whichever test runs first, so record it: when that
129+
// test is the one CI kills, this says whether the time went here or in the body.
130+
// Reuses the count the loop already fetched — diagnostics must not add a
131+
// fallible request that could itself fail or stall the setup.
132+
info!(
133+
"region split finished in {:?} ({} regions)",
134+
start_time.elapsed(),
135+
observed_regions
136+
);
126137

127138
Ok(())
128139
}

tests/failpoint_tests.rs

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ use tikv_client::RetryOptions;
2323
use tikv_client::TransactionClient;
2424
use 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]
2845
async 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

Comments
 (0)