mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-04 12:02:55 +00:00
safekeeper: add remote_path to Timeline
It is used in many places, let's reduce number of ? on construction results.
This commit is contained in:
@@ -183,10 +183,10 @@ impl WalResidentTimeline {
|
||||
"Replacing uploaded partial segment in in-mem control file: {replace:?}"
|
||||
);
|
||||
|
||||
let remote_timeline_path = wal_backup::remote_timeline_path(&self.tli.ttid)?;
|
||||
let remote_timeline_path = &self.tli.remote_path;
|
||||
wal_backup::copy_partial_segment(
|
||||
&replace.previous.remote_path(&remote_timeline_path),
|
||||
&replace.current.remote_path(&remote_timeline_path),
|
||||
&replace.previous.remote_path(remote_timeline_path),
|
||||
&replace.current.remote_path(remote_timeline_path),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use camino::Utf8PathBuf;
|
||||
use remote_storage::RemotePath;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::fs::{self};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
@@ -36,7 +37,7 @@ use crate::state::{EvictionState, TimelineMemState, TimelinePersistentState, Tim
|
||||
use crate::timeline_guard::ResidenceGuard;
|
||||
use crate::timeline_manager::{AtomicStatus, ManagerCtl};
|
||||
use crate::timelines_set::TimelinesSet;
|
||||
use crate::wal_backup::{self};
|
||||
use crate::wal_backup::{self, remote_timeline_path};
|
||||
use crate::wal_backup_partial::PartialRemoteSegment;
|
||||
use crate::{control_file, safekeeper::UNKNOWN_SERVER_VERSION};
|
||||
|
||||
@@ -469,6 +470,7 @@ impl From<TimelineError> for ApiError {
|
||||
/// It also holds SharedState and provides mutually exclusive access to it.
|
||||
pub struct Timeline {
|
||||
pub ttid: TenantTimelineId,
|
||||
pub remote_path: RemotePath,
|
||||
|
||||
/// Used to broadcast commit_lsn updates to all background jobs.
|
||||
commit_lsn_watch_tx: watch::Sender<Lsn>,
|
||||
@@ -519,8 +521,10 @@ impl Timeline {
|
||||
let (shared_state_version_tx, shared_state_version_rx) = watch::channel(0);
|
||||
|
||||
let walreceivers = WalReceivers::new();
|
||||
let remote_path = remote_timeline_path(&ttid)?;
|
||||
Ok(Timeline {
|
||||
ttid,
|
||||
remote_path,
|
||||
commit_lsn_watch_tx,
|
||||
commit_lsn_watch_rx,
|
||||
term_flush_lsn_watch_tx,
|
||||
@@ -557,8 +561,10 @@ impl Timeline {
|
||||
TimelinePersistentState::new(&ttid, server_info, vec![], commit_lsn, local_start_lsn);
|
||||
|
||||
let walreceivers = WalReceivers::new();
|
||||
let remote_path = remote_timeline_path(&ttid)?;
|
||||
Ok(Timeline {
|
||||
ttid,
|
||||
remote_path,
|
||||
commit_lsn_watch_tx,
|
||||
commit_lsn_watch_rx,
|
||||
term_flush_lsn_watch_tx,
|
||||
|
||||
@@ -167,7 +167,7 @@ async fn redownload_partial_segment(
|
||||
partial: &PartialRemoteSegment,
|
||||
) -> anyhow::Result<()> {
|
||||
let tmp_file = mgr.tli.timeline_dir().join("remote_partial.tmp");
|
||||
let remote_segfile = remote_segment_path(mgr, partial)?;
|
||||
let remote_segfile = remote_segment_path(mgr, partial);
|
||||
|
||||
debug!(
|
||||
"redownloading partial segment: {} -> {}",
|
||||
@@ -252,7 +252,7 @@ async fn do_validation(
|
||||
);
|
||||
}
|
||||
|
||||
let remote_segfile = remote_segment_path(mgr, partial)?;
|
||||
let remote_segfile = remote_segment_path(mgr, partial);
|
||||
let mut remote_reader: std::pin::Pin<Box<dyn AsyncRead + Send + Sync>> =
|
||||
wal_backup::read_object(&remote_segfile, 0).await?;
|
||||
|
||||
@@ -279,12 +279,8 @@ fn local_segment_path(mgr: &Manager, partial: &PartialRemoteSegment) -> Utf8Path
|
||||
local_partial_segfile
|
||||
}
|
||||
|
||||
fn remote_segment_path(
|
||||
mgr: &Manager,
|
||||
partial: &PartialRemoteSegment,
|
||||
) -> anyhow::Result<RemotePath> {
|
||||
let remote_timeline_path = wal_backup::remote_timeline_path(&mgr.tli.ttid)?;
|
||||
Ok(partial.remote_path(&remote_timeline_path))
|
||||
fn remote_segment_path(mgr: &Manager, partial: &PartialRemoteSegment) -> RemotePath {
|
||||
partial.remote_path(&mgr.tli.remote_path)
|
||||
}
|
||||
|
||||
/// Compare first `n` bytes of two readers. If the bytes differ, return an error.
|
||||
|
||||
@@ -315,7 +315,7 @@ async fn backup_lsn_range(
|
||||
anyhow::bail!("parallel_jobs must be >= 1");
|
||||
}
|
||||
|
||||
let remote_timeline_path = remote_timeline_path(&timeline.ttid)?;
|
||||
let remote_timeline_path = &timeline.remote_path;
|
||||
let start_lsn = *backup_lsn;
|
||||
let segments = get_segments(start_lsn, end_lsn, wal_seg_size);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ use crate::{
|
||||
safekeeper::Term,
|
||||
timeline::WalResidentTimeline,
|
||||
timeline_manager::StateSnapshot,
|
||||
wal_backup::{self, remote_timeline_path},
|
||||
wal_backup::{self},
|
||||
SafeKeeperConf,
|
||||
};
|
||||
|
||||
@@ -388,13 +388,7 @@ pub async fn main_task(
|
||||
let wal_seg_size = tli.get_wal_seg_size().await;
|
||||
|
||||
let local_prefix = tli.get_timeline_dir();
|
||||
let remote_timeline_path = match remote_timeline_path(&tli.ttid) {
|
||||
Ok(path) => path,
|
||||
Err(e) => {
|
||||
error!("failed to create remote path: {:?}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let remote_timeline_path = tli.remote_path.clone();
|
||||
|
||||
let mut backup = PartialBackup {
|
||||
wal_seg_size,
|
||||
|
||||
Reference in New Issue
Block a user