mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-17 13:10:38 +00:00
Compare commits
15 Commits
release-co
...
on_demand_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c4bed27be | ||
|
|
fdf0f1bdc0 | ||
|
|
0bdd388dd8 | ||
|
|
712b4cf83c | ||
|
|
15b6bb5026 | ||
|
|
61d642e541 | ||
|
|
1d24b887b8 | ||
|
|
955175c791 | ||
|
|
5fb0bcdd6a | ||
|
|
f146fa86f8 | ||
|
|
961008116b | ||
|
|
42d2d3addc | ||
|
|
06d0bed566 | ||
|
|
aa367e5d82 | ||
|
|
6b76e1c526 |
@@ -897,32 +897,28 @@ impl ComputeNode {
|
||||
let mut client = config.connect(NoTls)?;
|
||||
let pageserver_connect_micros = start_time.elapsed().as_micros() as u64;
|
||||
|
||||
let basebackup_cmd = match lsn {
|
||||
Lsn(0) => {
|
||||
if spec.spec.mode != ComputeMode::Primary {
|
||||
format!(
|
||||
"basebackup {} {} --gzip --replica",
|
||||
spec.tenant_id, spec.timeline_id
|
||||
)
|
||||
} else {
|
||||
format!("basebackup {} {} --gzip", spec.tenant_id, spec.timeline_id)
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if spec.spec.mode != ComputeMode::Primary {
|
||||
format!(
|
||||
"basebackup {} {} {} --gzip --replica",
|
||||
spec.tenant_id, spec.timeline_id, lsn
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"basebackup {} {} {} --gzip",
|
||||
spec.tenant_id, spec.timeline_id, lsn
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let tenant_id = spec.tenant_id.to_string();
|
||||
let timeline_id = spec.timeline_id.to_string();
|
||||
let lsn_str = lsn.to_string();
|
||||
let mut cmd = Vec::new();
|
||||
cmd.push("basebackup");
|
||||
cmd.push(&tenant_id);
|
||||
cmd.push(&timeline_id);
|
||||
if lsn != Lsn::INVALID {
|
||||
cmd.push(&lsn_str);
|
||||
}
|
||||
cmd.push("--gzip");
|
||||
if spec.spec.mode != ComputeMode::Primary {
|
||||
cmd.push("--replica");
|
||||
}
|
||||
if spec
|
||||
.spec
|
||||
.features
|
||||
.contains(&ComputeFeature::LazySlruDownload)
|
||||
{
|
||||
cmd.push("--lazy-slru-download")
|
||||
}
|
||||
let basebackup_cmd = cmd.join(" ");
|
||||
let copyreader = client.copy_out(basebackup_cmd.as_str())?;
|
||||
let mut measured_reader = MeasuredReader::new(copyreader);
|
||||
let mut bufreader = std::io::BufReader::new(&mut measured_reader);
|
||||
|
||||
@@ -183,6 +183,9 @@ pub enum ComputeFeature {
|
||||
/// track short-lived connections as user activity.
|
||||
ActivityMonitorExperimental,
|
||||
|
||||
/// Download all SLRU files on demand
|
||||
LazySlruDownload,
|
||||
|
||||
/// This is a special feature flag that is used to represent unknown feature flags.
|
||||
/// Basically all unknown to enum flags are represented as this one. See unit test
|
||||
/// `parse_unknown_features()` for more details.
|
||||
|
||||
@@ -73,6 +73,7 @@ impl From<GetVectoredError> for BasebackupError {
|
||||
/// * When working without safekeepers. In this situation it is important to match the lsn
|
||||
/// we are taking basebackup on with the lsn that is used in pageserver's walreceiver
|
||||
/// to start the replication.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn send_basebackup_tarball<'a, W>(
|
||||
write: &'a mut W,
|
||||
timeline: &'a Timeline,
|
||||
@@ -80,6 +81,7 @@ pub async fn send_basebackup_tarball<'a, W>(
|
||||
prev_lsn: Option<Lsn>,
|
||||
full_backup: bool,
|
||||
replica: bool,
|
||||
lazy_slru_download_enabled: bool,
|
||||
ctx: &'a RequestContext,
|
||||
) -> Result<(), BasebackupError>
|
||||
where
|
||||
@@ -131,8 +133,8 @@ where
|
||||
};
|
||||
|
||||
info!(
|
||||
"taking basebackup lsn={}, prev_lsn={} (full_backup={}, replica={})",
|
||||
backup_lsn, prev_lsn, full_backup, replica
|
||||
"taking basebackup lsn={}, prev_lsn={} (full_backup={}, replica={}, lazy_slru_download_enabled={})",
|
||||
backup_lsn, prev_lsn, full_backup, replica, lazy_slru_download_enabled
|
||||
);
|
||||
|
||||
let basebackup = Basebackup {
|
||||
@@ -142,6 +144,7 @@ where
|
||||
prev_record_lsn: prev_lsn,
|
||||
full_backup,
|
||||
replica,
|
||||
lazy_slru_download_enabled,
|
||||
ctx,
|
||||
io_concurrency: IoConcurrency::spawn_from_conf(
|
||||
timeline.conf,
|
||||
@@ -170,6 +173,7 @@ where
|
||||
prev_record_lsn: Lsn,
|
||||
full_backup: bool,
|
||||
replica: bool,
|
||||
lazy_slru_download_enabled: bool,
|
||||
ctx: &'a RequestContext,
|
||||
io_concurrency: IoConcurrency,
|
||||
}
|
||||
@@ -308,7 +312,10 @@ where
|
||||
self.timeline.pg_version,
|
||||
)?;
|
||||
|
||||
let lazy_slru_download = self.timeline.get_lazy_slru_download() && !self.full_backup;
|
||||
let lazy_slru_download = self
|
||||
.timeline
|
||||
.get_lazy_slru_download(self.lazy_slru_download_enabled)
|
||||
&& !self.full_backup;
|
||||
|
||||
let pgversion = self.timeline.pg_version;
|
||||
let subdirs = dispatch_pgversion!(pgversion, &pgv::bindings::PGDATA_SUBDIRS[..]);
|
||||
|
||||
@@ -2394,6 +2394,7 @@ impl PageServerHandler {
|
||||
full_backup: bool,
|
||||
gzip: bool,
|
||||
replica: bool,
|
||||
lazy_slru_download: bool,
|
||||
ctx: &RequestContext,
|
||||
) -> Result<(), QueryError>
|
||||
where
|
||||
@@ -2461,6 +2462,7 @@ impl PageServerHandler {
|
||||
prev_lsn,
|
||||
full_backup,
|
||||
replica,
|
||||
lazy_slru_download,
|
||||
&ctx,
|
||||
)
|
||||
.await
|
||||
@@ -2484,6 +2486,7 @@ impl PageServerHandler {
|
||||
prev_lsn,
|
||||
full_backup,
|
||||
replica,
|
||||
lazy_slru_download,
|
||||
&ctx,
|
||||
)
|
||||
.await
|
||||
@@ -2501,6 +2504,7 @@ impl PageServerHandler {
|
||||
prev_lsn,
|
||||
full_backup,
|
||||
replica,
|
||||
lazy_slru_download,
|
||||
&ctx,
|
||||
)
|
||||
.await
|
||||
@@ -2550,7 +2554,7 @@ impl PageServerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// `basebackup tenant timeline [lsn] [--gzip] [--replica]`
|
||||
/// `basebackup tenant timeline [lsn] [--gzip] [--replica] [--lazy-slru-download]`
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
struct BaseBackupCmd {
|
||||
tenant_id: TenantId,
|
||||
@@ -2558,6 +2562,7 @@ struct BaseBackupCmd {
|
||||
lsn: Option<Lsn>,
|
||||
gzip: bool,
|
||||
replica: bool,
|
||||
lazy_slru_download: bool,
|
||||
}
|
||||
|
||||
/// `fullbackup tenant timeline [lsn] [prev_lsn]`
|
||||
@@ -2690,6 +2695,7 @@ impl BaseBackupCmd {
|
||||
|
||||
let mut gzip = false;
|
||||
let mut replica = false;
|
||||
let mut lazy_slru_download = false;
|
||||
|
||||
for ¶m in ¶meters[flags_parse_from..] {
|
||||
match param {
|
||||
@@ -2705,6 +2711,12 @@ impl BaseBackupCmd {
|
||||
}
|
||||
replica = true
|
||||
}
|
||||
"--lazy-slru-download" => {
|
||||
if lazy_slru_download {
|
||||
bail!("duplicate parameter for basebackup command: {param}")
|
||||
}
|
||||
lazy_slru_download = true
|
||||
}
|
||||
_ => bail!("invalid parameter for basebackup command: {param}"),
|
||||
}
|
||||
}
|
||||
@@ -2714,6 +2726,7 @@ impl BaseBackupCmd {
|
||||
lsn,
|
||||
gzip,
|
||||
replica,
|
||||
lazy_slru_download,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2928,6 +2941,7 @@ where
|
||||
lsn,
|
||||
gzip,
|
||||
replica,
|
||||
lazy_slru_download,
|
||||
}) => {
|
||||
tracing::Span::current()
|
||||
.record("tenant_id", field::display(tenant_id))
|
||||
@@ -2949,6 +2963,7 @@ where
|
||||
false,
|
||||
gzip,
|
||||
replica,
|
||||
lazy_slru_download,
|
||||
&ctx,
|
||||
)
|
||||
.await?;
|
||||
@@ -2986,6 +3001,7 @@ where
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
&ctx,
|
||||
)
|
||||
.await?;
|
||||
@@ -3120,7 +3136,8 @@ mod tests {
|
||||
timeline_id,
|
||||
lsn: None,
|
||||
gzip: false,
|
||||
replica: false
|
||||
replica: false,
|
||||
lazy_slru_download: false
|
||||
})
|
||||
);
|
||||
let cmd =
|
||||
@@ -3132,7 +3149,8 @@ mod tests {
|
||||
timeline_id,
|
||||
lsn: None,
|
||||
gzip: true,
|
||||
replica: false
|
||||
replica: false,
|
||||
lazy_slru_download: false
|
||||
})
|
||||
);
|
||||
let cmd =
|
||||
@@ -3144,7 +3162,8 @@ mod tests {
|
||||
timeline_id,
|
||||
lsn: None,
|
||||
gzip: false,
|
||||
replica: false
|
||||
replica: false,
|
||||
lazy_slru_download: false
|
||||
})
|
||||
);
|
||||
let cmd = PageServiceCmd::parse(&format!("basebackup {tenant_id} {timeline_id} 0/16ABCDE"))
|
||||
@@ -3156,7 +3175,8 @@ mod tests {
|
||||
timeline_id,
|
||||
lsn: Some(Lsn::from_str("0/16ABCDE").unwrap()),
|
||||
gzip: false,
|
||||
replica: false
|
||||
replica: false,
|
||||
lazy_slru_download: false
|
||||
})
|
||||
);
|
||||
let cmd = PageServiceCmd::parse(&format!(
|
||||
@@ -3170,7 +3190,23 @@ mod tests {
|
||||
timeline_id,
|
||||
lsn: None,
|
||||
gzip: true,
|
||||
replica: true
|
||||
replica: true,
|
||||
lazy_slru_download: false
|
||||
})
|
||||
);
|
||||
let cmd = PageServiceCmd::parse(&format!(
|
||||
"basebackup {tenant_id} {timeline_id} --replica --gzip --lazy-slru-download"
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
cmd,
|
||||
PageServiceCmd::BaseBackup(BaseBackupCmd {
|
||||
tenant_id,
|
||||
timeline_id,
|
||||
lsn: None,
|
||||
gzip: true,
|
||||
replica: true,
|
||||
lazy_slru_download: true
|
||||
})
|
||||
);
|
||||
let cmd = PageServiceCmd::parse(&format!(
|
||||
@@ -3184,7 +3220,8 @@ mod tests {
|
||||
timeline_id,
|
||||
lsn: Some(Lsn::from_str("0/16ABCDE").unwrap()),
|
||||
gzip: true,
|
||||
replica: true
|
||||
replica: true,
|
||||
lazy_slru_download: false
|
||||
})
|
||||
);
|
||||
let cmd = PageServiceCmd::parse(&format!("fullbackup {tenant_id} {timeline_id}")).unwrap();
|
||||
|
||||
@@ -2490,12 +2490,11 @@ impl Timeline {
|
||||
tenant_conf.is_gc_blocked_by_lsn_lease_deadline()
|
||||
}
|
||||
|
||||
pub(crate) fn get_lazy_slru_download(&self) -> bool {
|
||||
pub(crate) fn get_lazy_slru_download(&self, lazy_slru_download_enabled_by_cp: bool) -> bool {
|
||||
let tenant_conf = self.tenant_conf.load();
|
||||
tenant_conf
|
||||
.tenant_conf
|
||||
.lazy_slru_download
|
||||
.unwrap_or(self.conf.default_tenant_conf.lazy_slru_download)
|
||||
tenant_conf.tenant_conf.lazy_slru_download.unwrap_or(
|
||||
lazy_slru_download_enabled_by_cp || self.conf.default_tenant_conf.lazy_slru_download,
|
||||
)
|
||||
}
|
||||
|
||||
/// Checks if a get page request should get perf tracing
|
||||
|
||||
Reference in New Issue
Block a user