Avoiding Tablespace path collision for primary and standby - Mailing list pgsql-hackers

From Ashwin Agrawal
Subject Avoiding Tablespace path collision for primary and standby
Date
Msg-id CALfoeisEF92F5nJ-aAcuWTvF_Aogxq_1bHLem_kVfM_tHc2mfg@mail.gmail.com
Whole thread Raw
Responses Re: Avoiding Tablespace path collision for primary and standby  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Currently, if primary and standby are setup on same machine (which is always the case for development), CREATE TABLESPACE xyz LOCATION '/abc', primary and mirror both write to "/abc/TABLESPACE_VERSION_DIRECTORY" directory. Collision is certainly not an issue in any production deployment but seems still solving the same for development is extremely helpful.

Proposing to create directory with timestamp at time of creating tablespace and create symbolic link to it instead. So, would be something like "/abc/PG_<timestamp>/TABLESPACE_VERSION_DIRECTORY". This helps avoid collision of primary and standby as timestamps would differ between primary creating the tablespace and mirror replaying the record for the same.

Ideally other advantage of this scheme is creating that additional TABLESPACE_VERSION_DIRECTORY inside can also be eliminated as even during pg_upgrade the paths will not collide. So, it helps to avoid constructing this additional string part at multiple places in code for tablespace access.

Since this is on-disk change yes may have impact to existing tools.

Attaching the patch to showcase the proposed. Tested by creating tablespace with primary and standby on same machine, also tablespace test passes.

Attachment

pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: XLogWrite uses palloc within a critical section
Next
From: Aleksander Alekseev
Date:
Subject: Re: [GSoC] github repo and initial work