diff --git a/pageserver/src/layered_repository.rs b/pageserver/src/layered_repository.rs index fdd03ecf8b..af6c7ba9fd 100644 --- a/pageserver/src/layered_repository.rs +++ b/pageserver/src/layered_repository.rs @@ -2210,6 +2210,9 @@ impl LayeredTimeline { LsnForTimestamp::Past(lsn) => { debug!("past({})", lsn); } + LsnForTimestamp::NoData(lsn) => { + debug!("nodata({})", lsn); + } } debug!("pitr_cutoff_lsn = {:?}", pitr_cutoff_lsn) } diff --git a/pageserver/src/page_service.rs b/pageserver/src/page_service.rs index 77c320a181..22002fdbab 100644 --- a/pageserver/src/page_service.rs +++ b/pageserver/src/page_service.rs @@ -554,7 +554,7 @@ impl PageServerHandler { // Create empty timeline info!("creating new timeline"); let repo = tenant_mgr::get_repository_for_tenant(tenant_id)?; - let timeline = repo.create_empty_timeline(timeline_id, Lsn(0))?; + let timeline = repo.create_empty_timeline(timeline_id, base_lsn)?; let repartition_distance = repo.get_checkpoint_distance(); let mut datadir_timeline = DatadirTimeline::::new(timeline, repartition_distance); @@ -1151,6 +1151,7 @@ impl postgres_backend::Handler for PageServerHandler { LsnForTimestamp::Present(lsn) => format!("{}", lsn), LsnForTimestamp::Future(_lsn) => "future".into(), LsnForTimestamp::Past(_lsn) => "past".into(), + LsnForTimestamp::NoData(_lsn) => "nodata".into(), }; pgb.write_message_noflush(&BeMessage::DataRow(&[Some(result.as_bytes())]))?; pgb.write_message(&BeMessage::CommandComplete(b"SELECT 1"))?; diff --git a/pageserver/src/pgdatadir_mapping.rs b/pageserver/src/pgdatadir_mapping.rs index ce305a55f4..9dbae74074 100644 --- a/pageserver/src/pgdatadir_mapping.rs +++ b/pageserver/src/pgdatadir_mapping.rs @@ -51,6 +51,7 @@ pub enum LsnForTimestamp { Present(Lsn), Future(Lsn), Past(Lsn), + NoData(Lsn), } impl DatadirTimeline { @@ -263,7 +264,7 @@ impl DatadirTimeline { (false, false) => { // This can happen if no commit records have been processed yet, e.g. // just after importing a cluster. - bail!("no commit timestamps found"); + Ok(LsnForTimestamp::NoData(max_lsn)) } (true, false) => { // Didn't find any commit timestamps larger than the request diff --git a/test_runner/batch_others/test_import.py b/test_runner/batch_others/test_import.py index e478103313..63dc42ee3e 100644 --- a/test_runner/batch_others/test_import.py +++ b/test_runner/batch_others/test_import.py @@ -191,3 +191,8 @@ def test_import_from_pageserver(test_output_dir, pg_bin, vanilla_pg, neon_env_bu # Check it's the same as the first fullbackup # TODO pageserver should be checking checksum assert os.path.getsize(tar_output_file) == os.path.getsize(new_tar_output_file) + + # Check that gc works + psconn = env.pageserver.connect() + pscur = psconn.cursor() + pscur.execute(f"do_gc {tenant.hex} {timeline} 0")