resolve conflicts

This commit is contained in:
Stas Kelvich
2024-09-12 10:37:07 +01:00
2 changed files with 30 additions and 16 deletions

View File

@@ -1,10 +1,26 @@
use anyhow;
use camino::Utf8PathBuf;
use clap::Parser;
use pageserver::{pg_import, virtual_file::{self, api::IoEngineKind}};
use utils::logging::{self, LogFormat, TracingErrorLayerEnablement};
fn main() -> anyhow::Result<()> {
println!("Hey!");
//project_git_version!(GIT_VERSION);
#[derive(Parser)]
#[command(
//version = GIT_VERSION,
about = "Utility to import a Postgres data directory directly into image layers",
//long_about = "..."
)]
struct CliOpts {
/// Input Postgres data directory
pgdata: Utf8PathBuf,
/// Path to local dir where the layer files will be stored
dest_path: Utf8PathBuf,
}
fn main() -> anyhow::Result<()> {
logging::init(
LogFormat::Plain,
TracingErrorLayerEnablement::EnableWithRustLogFilter,
@@ -21,7 +37,15 @@ fn main() -> anyhow::Result<()> {
.enable_all()
.build()?;
rt.block_on(pg_import::do_import())?;
let cli = CliOpts::parse();
rt.block_on(async_main(cli))?;
Ok(())
}
async fn async_main(cli: CliOpts) -> anyhow::Result<()> {
let mut import = pg_import::PgImportEnv::init().await?;
import.import_datadir(&cli.pgdata, &cli.dest_path).await?;
Ok(())
}

View File

@@ -18,16 +18,6 @@ use tokio::io::AsyncReadExt;
use pageserver_api::key::Key;
pub async fn do_import() -> anyhow::Result<()> {
let mut import = PgImportEnv::init().await?;
import.import_datadir(&Utf8PathBuf::from("pg_in"), &Utf8PathBuf::from("pg_out")).await?;
Ok(())
}
pub struct PgImportEnv {
ctx: RequestContext,
conf: &'static PageServerConf,
@@ -37,7 +27,7 @@ pub struct PgImportEnv {
impl PgImportEnv {
async fn init() -> anyhow::Result<PgImportEnv> {
pub async fn init() -> anyhow::Result<PgImportEnv> {
let ctx: RequestContext = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error);
let config = toml_edit::Document::new();
let conf = PageServerConf::parse_and_validate(
@@ -63,7 +53,7 @@ impl PgImportEnv {
})
}
async fn import_datadir(&mut self, pgdata_path: &Utf8Path, _tenant_path: &Utf8Path) -> anyhow::Result<()> {
pub async fn import_datadir(&mut self, pgdata_path: &Utf8Path, _tenant_path: &Utf8Path) -> anyhow::Result<()> {
let pgdata_lsn = import_datadir::get_lsn_from_controlfile(&pgdata_path)?.align();