Repository navigation
Relocate source tablespaces inside shadow's data dir - #322
Open
timmclaughlin wants to merge 1 commit into
Open
timmclaughlin wants to merge 1 commit into
timmclaughlin wants to merge 1 commit into
Conversation
timmclaughlin
force-pushed
the
fix/bootstrap-tablespaces
branch
from
November 18, 2026 19:52
0e54cb5 to
ec12a40
Compare
Backups land a user tablespace as a real pg_tblspc/<oid> directory beside a tablespace_map naming the source location. Shadow recovery then either fails removing that directory to re-point it, or panics at consistency on a non-symlink pg_tblspc entry. After extraction, move each tablespace under walshadow_tblspc/<oid>, link it back by relative path, and retire the map as tablespace_map.old. Direct BASE_BACKUP tablespace archives landed over the data dir root; root them at pg_tblspc/<oid>/ to match the object-store layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serprex
force-pushed
the
fix/bootstrap-tablespaces
branch
from
November 23, 2026 08:44
ec12a40 to
a4e5d82
Compare
Member
|
this is somewhat incompatible with existing plan https://github.com/ClickHouse/walshadow/blob/main/plans/tablespaces.md this hasn't been prioritized, but does #340 address your needs? |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An object-store bootstrap of a source with a user tablespace (only temp files in it) completed, but the first shadow start failed and kept failing.
With
tablespace_mapin the data dir:With the map moved aside, recovery reached consistency and then:
Root cause
pg_tblspc/<oid>/PG_<ver>_<cat>/…, so extraction writes a real directory there, plus atablespace_mapline<oid> <source location>.pg_tblspcentry with a symlink to the map's location. It can onlyrmdirthe entry, which fails on the populated directory. The location doesn't exist on the walshadow host in any case.pg_tblspcentry to be a symlink once recovery is consistent, unlessallow_in_place_tablespacesis set.BASE_BACKUP (TABLESPACE_MAP true)sends each tablespace as its own archive, rooted at the tablespace.DirectSourcepumped those over the data dir root (<shadow>/PG_18_…/<db>/…), next to atablespace_mapthat pointed recovery at the source location.Fix
shadow_tablespaces::relocateruns inspawn_greenfield_bootstraponcesource.runreturns. For each tablespace named by the map or present underpg_tblspc:pg_tblspc/<oid>towalshadow_tblspc/<oid>inside the shadow data dir;pg_tblspc/<oid>→../walshadow_tblspc/<oid>. The link is relative, so the data dir can still be moved or remounted;tablespace_mapis renamed totablespace_map.old, which is what recovery itself does after applying it. Links land and are fsynced first.pg_tblspc/<oid>/(PumpTarget::for_tablespace), the same layout as object store. Both modes then go through the same relocation.discard_partialremoves it along with everything else.Not changed: rows of tables stored in a non-default tablespace are still not page-walked, and replaying a
CREATE TABLESPACEissued after bootstrap still targets the source path.docs/limitations.mdnow states both.Testing
shadow_tablespaces): a landed tablespace moves home and the map retires, and a second pass finds the link already in place; a mapped tablespace with no files gets an empty home; a dir with no tablespaces is left untouched; foreign links and malformed maps are refused.backup_source::tablespace_archive_lands_under_pg_tblspctests/bootstrap_tablespace_e2e.rs(PG 18): the source has a tablespace holding a table. Bootstrap viaDirectSourceand viaObjectStoreSource(a wal-rus push). Then stop the source, remove its tablespace location, and recover each shadow from archived WAL. Each reaches hot standby and reads the table from the relocated tablespace. With relocation disabled the test fails with the samecould not remove directory "pg_tblspc/<oid>"FATAL.bootstrap_direct_e2eandbootstrap_object_store_e2estill pass.cargo fmt --check,cargo clippy --workspace --all-targets -D warningsandcargo test --libpass, apart from the two existing macOS-only failures (sync_filesystem_flushes_existing_dir_only,skips_files_with_non_utf8_names).🤖 Generated with Claude Code