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.
adding_timestamp_to_tablespace_path
Description: Binary data