Skip to content

Commit 11c1621

Browse files
skyzhKonstantin Knizhnik
authored andcommitted
fix(pageserver): include aux file in basebackup only once (#8207)
Extracted from #6560, currently we include multiple copies of aux files in the basebackup. ## Summary of changes Fix the loop. Signed-off-by: Alex Chi Z <chi@neon.tech> Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
1 parent 1ec1c6f commit 11c1621

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

pageserver/src/basebackup.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -348,35 +348,36 @@ where
348348
self.add_rel(rel, rel).await?;
349349
}
350350
}
351+
}
351352

352-
for (path, content) in self
353-
.timeline
354-
.list_aux_files(self.lsn, self.ctx)
355-
.await
356-
.map_err(|e| BasebackupError::Server(e.into()))?
357-
{
358-
if path.starts_with("pg_replslot") {
359-
let offs = pg_constants::REPL_SLOT_ON_DISK_OFFSETOF_RESTART_LSN;
360-
let restart_lsn = Lsn(u64::from_le_bytes(
361-
content[offs..offs + 8].try_into().unwrap(),
362-
));
363-
info!("Replication slot {} restart LSN={}", path, restart_lsn);
364-
min_restart_lsn = Lsn::min(min_restart_lsn, restart_lsn);
365-
} else if path == "pg_logical/replorigin_checkpoint" {
366-
// replorigin_checkoint is written only on compute shutdown, so it contains
367-
// deteriorated values. So we generate our own version of this file for the particular LSN
368-
// based on information about replorigins extracted from transaction commit records.
369-
// In future we will not generate AUX record for "pg_logical/replorigin_checkpoint" at all,
370-
// but now we should handle (skip) it for backward compatibility.
371-
continue;
372-
}
373-
let header = new_tar_header(&path, content.len() as u64)?;
374-
self.ar
375-
.append(&header, &*content)
376-
.await
377-
.context("could not add aux file to basebackup tarball")?;
353+
for (path, content) in self
354+
.timeline
355+
.list_aux_files(self.lsn, self.ctx)
356+
.await
357+
.map_err(|e| BasebackupError::Server(e.into()))?
358+
{
359+
if path.starts_with("pg_replslot") {
360+
let offs = pg_constants::REPL_SLOT_ON_DISK_OFFSETOF_RESTART_LSN;
361+
let restart_lsn = Lsn(u64::from_le_bytes(
362+
content[offs..offs + 8].try_into().unwrap(),
363+
));
364+
info!("Replication slot {} restart LSN={}", path, restart_lsn);
365+
min_restart_lsn = Lsn::min(min_restart_lsn, restart_lsn);
366+
} else if path == "pg_logical/replorigin_checkpoint" {
367+
// replorigin_checkoint is written only on compute shutdown, so it contains
368+
// deteriorated values. So we generate our own version of this file for the particular LSN
369+
// based on information about replorigins extracted from transaction commit records.
370+
// In future we will not generate AUX record for "pg_logical/replorigin_checkpoint" at all,
371+
// but now we should handle (skip) it for backward compatibility.
372+
continue;
378373
}
374+
let header = new_tar_header(&path, content.len() as u64)?;
375+
self.ar
376+
.append(&header, &*content)
377+
.await
378+
.context("could not add aux file to basebackup tarball")?;
379379
}
380+
380381
if min_restart_lsn != Lsn::MAX {
381382
info!(
382383
"Min restart LSN for logical replication is {}",

0 commit comments

Comments
 (0)