mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-26 07:39:58 +00:00
Don't error if timeline offload is already in progress (#12428)
Don't print errors like: ``` Compaction failed 1 times, retrying in 2s: Failed to offload timeline: Unexpected offload error: Timeline deletion is already in progress ``` Print it at info log level instead. https://github.com/neondatabase/cloud/issues/30666
This commit is contained in:
@@ -2438,6 +2438,7 @@ async fn timeline_offload_handler(
|
|||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
match e {
|
match e {
|
||||||
OffloadError::Cancelled => ApiError::ResourceUnavailable("Timeline shutting down".into()),
|
OffloadError::Cancelled => ApiError::ResourceUnavailable("Timeline shutting down".into()),
|
||||||
|
OffloadError::AlreadyInProgress => ApiError::Conflict("Timeline already being offloaded or deleted".into()),
|
||||||
_ => ApiError::InternalServerError(anyhow!(e))
|
_ => ApiError::InternalServerError(anyhow!(e))
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -3285,6 +3285,7 @@ impl TenantShard {
|
|||||||
.or_else(|err| match err {
|
.or_else(|err| match err {
|
||||||
// Ignore this, we likely raced with unarchival.
|
// Ignore this, we likely raced with unarchival.
|
||||||
OffloadError::NotArchived => Ok(()),
|
OffloadError::NotArchived => Ok(()),
|
||||||
|
OffloadError::AlreadyInProgress => Ok(()),
|
||||||
err => Err(err),
|
err => Err(err),
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ pub(crate) enum OffloadError {
|
|||||||
NotArchived,
|
NotArchived,
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
RemoteStorage(anyhow::Error),
|
RemoteStorage(anyhow::Error),
|
||||||
|
#[error("Offload or deletion already in progress")]
|
||||||
|
AlreadyInProgress,
|
||||||
#[error("Unexpected offload error: {0}")]
|
#[error("Unexpected offload error: {0}")]
|
||||||
Other(anyhow::Error),
|
Other(anyhow::Error),
|
||||||
}
|
}
|
||||||
@@ -44,20 +46,26 @@ pub(crate) async fn offload_timeline(
|
|||||||
timeline.timeline_id,
|
timeline.timeline_id,
|
||||||
TimelineDeleteGuardKind::Offload,
|
TimelineDeleteGuardKind::Offload,
|
||||||
);
|
);
|
||||||
if let Err(DeleteTimelineError::HasChildren(children)) = delete_guard_res {
|
let (timeline, guard) = match delete_guard_res {
|
||||||
let is_archived = timeline.is_archived();
|
Ok(timeline_and_guard) => timeline_and_guard,
|
||||||
if is_archived == Some(true) {
|
Err(DeleteTimelineError::HasChildren(children)) => {
|
||||||
tracing::error!("timeline is archived but has non-archived children: {children:?}");
|
let is_archived = timeline.is_archived();
|
||||||
|
if is_archived == Some(true) {
|
||||||
|
tracing::error!("timeline is archived but has non-archived children: {children:?}");
|
||||||
|
return Err(OffloadError::NotArchived);
|
||||||
|
}
|
||||||
|
tracing::info!(
|
||||||
|
?is_archived,
|
||||||
|
"timeline is not archived and has unarchived children"
|
||||||
|
);
|
||||||
return Err(OffloadError::NotArchived);
|
return Err(OffloadError::NotArchived);
|
||||||
}
|
}
|
||||||
tracing::info!(
|
Err(DeleteTimelineError::AlreadyInProgress(_)) => {
|
||||||
?is_archived,
|
tracing::info!("timeline offload or deletion already in progress");
|
||||||
"timeline is not archived and has unarchived children"
|
return Err(OffloadError::AlreadyInProgress);
|
||||||
);
|
}
|
||||||
return Err(OffloadError::NotArchived);
|
Err(e) => return Err(OffloadError::Other(anyhow::anyhow!(e))),
|
||||||
};
|
};
|
||||||
let (timeline, guard) =
|
|
||||||
delete_guard_res.map_err(|e| OffloadError::Other(anyhow::anyhow!(e)))?;
|
|
||||||
|
|
||||||
let TimelineOrOffloaded::Timeline(timeline) = timeline else {
|
let TimelineOrOffloaded::Timeline(timeline) = timeline else {
|
||||||
tracing::error!("timeline already offloaded, but given timeline object");
|
tracing::error!("timeline already offloaded, but given timeline object");
|
||||||
|
|||||||
Reference in New Issue
Block a user