-
由 Taylor Vesely 提交于
This commit includes changes to the server to ensure that the utilities: pg_rewind and pg_basebackup can be changed to support recovery in a multi-segment-singular-host setting. We link pg_tblspc to a <dbid> subdirectory of the tablespace, rather than to the path of the tablespace directly, and we remove the <dbid> from the tablespace version directory. At the same time, we have designed towards preserving the response to pg_tablespace_location(<tablespace_oid>) such that it does not return the dbid suffix. The design is such that it is the responsibility of the utilities to append the dbid as and when required. Before this commit: * the symlink to the tablespace directory looks like: pg_tblspc/spcoid/ -> /<tablespace_location>/ * Under the symlink target, we would have the following: GPDB_MAJORVER_CATVER_db<dbid>/dboid/relfilenode * pg_tablespace_location(tsoid) returns: <tablespace_location> e.g. * pg_tblspc/20981/ -> /data1/tsp1 * Under /data1/tsp1: GPDB_6_201902061_db1/19849/192814 * pg_tablespace_location(20981) returns: /data1/tsp1 After this commit: * the symlink to the tablespace directory looks like: pg_tblspc/spcoid/ -> /<tablespace_location>/<dbid> * Under the symlink target, we would have the following: GPDB_MAJORVER_CATVER/dboid/relfilenode * pg_tablespace_location(tsoid) returns: <tablespace_location> e.g. * pg_tblspc/20981/ -> /data1/tsp1/1 * Under /data1/tsp1/1: GPDB_6_201902061/19849/192814 * pg_tablespace_location(20981) returns: /data1/tsp1 Motivation: When tablespaces were aligned to upstream postgres, while removing filespaces, we added the `tablespace_version_directory()` function to supply each segment with a unique tablespace directory name. This was accomplished by appending the 'magic' `GpIdentity.dbid` global variable to the `GP_TABLESPACE_VERSION_DIRECTORY` in `tablespace_version_directory()`. This is problematic for several reasons- but perhaps most severely is the fact that in order to use any code in libpgcommon.so that references this value, you need to first set the `GpIdentity.dbid` global, otherwise any functions that deal with tablespaces will be broken in unpredictable ways. An example is pg_rewind- where `GetRelationPath()` will not return a valid relation unless you repeatedly toggle the `GpIdentity.dbid` between the value of the source or target segment dependant on the context of which relfiles are being examined. This commit bumps the catalog version here we have made breaking changes in the tablespace filesystem layout. Co-authored-by: NAdam Berlin <aberlin@pivotal.io> Co-authored-by: NTaylor Vesely <tvesely@pivotal.io> Co-authored-by: NSoumyadeep Chakraborty <sochakraborty@pivotal.io>
42b915a2