Skip to content

Commit

Permalink
Assert the tenant to be active in unoffload_timeline (#9539)
Browse files Browse the repository at this point in the history
Currently, all callers of `unoffload_timeline` ensure that the tenant
the unoffload operation is called on is active. We rely on it being
active as we activate the timeline below and don't want to race with the
activation code of the tenant (in the worst case, activating a timeline
twice).

Therefore, add this assertion.

Part of #8088
  • Loading branch information
arpad-m authored Oct 29, 2024
1 parent 4df3987 commit 62f5d48
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pageserver/src/tenant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,18 @@ impl Tenant {
ctx: RequestContext,
) -> Result<Arc<Timeline>, TimelineArchivalError> {
info!("unoffloading timeline");

// We activate the timeline below manually, so this must be called on an active timeline.
// We expect callers of this function to ensure this.
match self.current_state() {
TenantState::Activating { .. }
| TenantState::Attaching
| TenantState::Broken { .. } => {
panic!("Timeline expected to be active")
}
TenantState::Stopping { .. } => return Err(TimelineArchivalError::Cancelled),
TenantState::Active => {}
}
let cancel = self.cancel.clone();

// Protect against concurrent attempts to use this TimelineId
Expand Down

1 comment on commit 62f5d48

@github-actions
Copy link

Choose a reason for hiding this comment

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

5274 tests run: 5051 passed, 1 failed, 222 skipped (full report)


Failures on Postgres 17

# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_remote_storage_upload_queue_retries[debug-pg17]"
Flaky tests (2)

Postgres 17

Postgres 14

Test coverage report is not available

The comment gets automatically updated with the latest test results
62f5d48 at 2024-10-29T01:24:00.946Z :recycle:

Please sign in to comment.