Skip to content
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

Don't panic when pausing stale unified schedulers #1761

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion runtime/src/installed_scheduler_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ impl BankWithScheduler {
);
assert!(
maybe_result_with_timings.is_none(),
"Premature result was returned from scheduler after paused"
"Premature result was returned from scheduler after paused (slot: {})",
bank.slot(),
Comment on lines +494 to +495
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be hit by the added test without fix.

);
}

Expand Down Expand Up @@ -635,6 +636,11 @@ impl BankWithSchedulerInner {
uninstalled_scheduler.return_to_pool();
(false, Some(result_with_timings))
}
SchedulerStatus::Stale(_pool, _result_with_timings) if reason.is_paused() => {
// Do nothing for pauses because the scheduler termination is guaranteed to be
// called later.
(true, None)
}
SchedulerStatus::Stale(_pool, _result_with_timings) => {
let result_with_timings = scheduler.transition_from_stale_to_unavailable();
(true, Some(result_with_timings))
Expand Down
45 changes: 45 additions & 0 deletions unified-scheduler-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,51 @@ mod tests {
assert_eq!(timings.metrics[ExecuteTimingType::CheckUs], 246);
}

#[test]
fn test_scheduler_pause_after_stale() {
solana_logger::setup();

let _progress = sleepless_testing::setup(&[
&TestCheckPoint::BeforeTimeoutListenerTriggered,
&CheckPoint::TimeoutListenerTriggered(0),
&CheckPoint::TimeoutListenerTriggered(1),
&TestCheckPoint::AfterTimeoutListenerTriggered,
]);

let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64));
let pool_raw = DefaultSchedulerPool::do_new(
None,
None,
None,
None,
ignored_prioritization_fee_cache,
SHORTENED_POOL_CLEANER_INTERVAL,
DEFAULT_MAX_POOLING_DURATION,
DEFAULT_MAX_USAGE_QUEUE_COUNT,
SHORTENED_TIMEOUT_DURATION,
);
let pool = pool_raw.clone();

let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000);
let bank = Bank::new_for_tests(&genesis_config);
let bank = setup_dummy_fork_graph(bank);

let context = SchedulingContext::new(bank.clone());

let scheduler = pool.take_scheduler(context);
let bank = BankWithScheduler::new(bank, Some(scheduler));
pool.register_timeout_listener(bank.create_timeout_listener());

sleepless_testing::at(TestCheckPoint::BeforeTimeoutListenerTriggered);
sleepless_testing::at(TestCheckPoint::AfterTimeoutListenerTriggered);

// This calls register_recent_blockhash() internally, which in turn calls
// BankWithScheduler::wait_for_paused_scheduler().
bank.fill_bank_with_ticks_for_tests();
let (result, _timings) = bank.wait_for_completed_scheduler().unwrap();
assert_matches!(result, Ok(()));
}

#[test]
fn test_scheduler_remain_stale_after_error() {
solana_logger::setup();
Expand Down