Documentation ¶
Index ¶
- Constants
- Variables
- func AlreadyRenamed(src, dst string) (bool, error)
- func DeleteDirectories(directories []string, requiredPaths []string, streams step.OutStreams) error
- func DeleteTablespaceDirectories(streams step.OutStreams, dirs []string) error
- func EnsureGpupgradeVersionsMatch(agentHosts []string) error
- func LocalVersion() (string, error)
- func NewID() string
- func PathExist(path string) (bool, error)
- func PathExistInFS(fsys fs.FS, path string) (bool, error)
- func RemoteVersion(host string) (string, error)
- func RenameDirectories(source, target string) error
- func ResetLocalVersionCommand()
- func ResetPgUpgradeCommand()
- func ResetRemoteVersionCommand()
- func RestorePgControl(dataDir string, streams step.OutStreams) error
- func Run(stdout, stderr io.Writer, opts *idl.PgOptions) error
- func SetLocalVersionCommand(command exectest.Command)
- func SetPgUpgradeCommand(cmdFunc exectest.Command)
- func SetRemoteVersionCommand(command exectest.Command)
- func TablespacePath(tablespaceLocation string, dbID int32, majorVersion uint64, ...) string
- func TempDataDir(datadir, segPrefix string, upgradeID string) string
- func VerifyDataDirectory(path ...string) error
- func VerifyLegacyTablespaceDbOIDDirectory(fsys fs.FS, dbOID string) (bool, error)
- func VerifyTablespaceDbIDDirectory(fsys fs.FS, dbID string) (bool, error)
- func VerifyTablespaceDirectory(path string) (bool, error)
- func VerifyTablespaceLocation(fsys fs.FS, tsLocation string) error
- type InvalidDataDirectoryError
- type MismatchedVersions
Constants ¶
const DefaultAgentPort = 6416
const DefaultDynamicLibraryPath = "$libdir"
const DefaultHubPort = 7527
const OldSuffix = ".old"
const PGVersion = "PG_VERSION"
Variables ¶
var ErrInvalidDataDirectory = errors.New("invalid data directory")
ErrInvalidDataDirectory is returned when a data directory does not look like a postgres data directory, and is returned by ArchiveAndSwapDirectories.
var PostgresFiles = []string{"postgresql.conf", PGVersion}
var StateDirectoryFiles = []string{"config.json", step.SubstepsFileName}
Functions ¶
func AlreadyRenamed ¶
AlreadyRenamed infers if a successful rename has already occurred by making sure src does not exist but dst does.
func DeleteDirectories ¶
func DeleteDirectories(directories []string, requiredPaths []string, streams step.OutStreams) error
Each directory in 'directories' is deleted only if every path in 'requiredPaths' exists in that directory.
func DeleteTablespaceDirectories ¶
func DeleteTablespaceDirectories(streams step.OutStreams, dirs []string) error
DeleteTablespaceDirectories deletes tablespace directories with the following format:
/dir/<fsname>/<datadir>/<tablespaceOid>/<dbId>/GPDB_<majorVersion>_<catalogVersion>
It first deletes the specified directory and checks if its safe to delete the parent dbID directory.
Tablespace Directory Structure When Upgrading from 5X =====================================================
DIR ├── filespace.txt ├── coordinator │ ├── demoDataDir-1 │ │ └── 16385 │ │ ├── 1 │ │ │ └── GPDB_6_301908232 │ │ │ └── 12812 │ │ │ └── 16389 │ │ └── 12094 │ │ ├── 16384 │ │ └── PG_VERSION ├── primary1 │ └── demoDataDir0 │ └── 16385 │ ├── 12094 │ │ ├── 16384 │ │ └── PG_VERSION │ └── 2 │ └── GPDB_6_301908232 │ └── 12812 │ └── 16389 GPDB 5X: /dir/<fsname>/<datadir>/<tablespaceOID>/<dbOID>/<relfilenode> GPDB 6X: /dir/<fsname>/<datadir>/<tablespaceOID>/<dbID>/GPDB_6_<catalogVersion>/<dbOID>/<relfilenode>
func LocalVersion ¶
func NewID ¶
func NewID() string
NewID creates a new unique upgrade ID that is reasonably unique across executions of the process.
func RemoteVersion ¶
func RenameDirectories ¶
RenameDirectories archives the source directory, and renames source to target. For example: source '/data/dbfast1/demoDataDir0' becomes archive '/data/dbfast1/demoDataDir.123ABC.0.old' target '/data/dbfast1/demoDataDir.123ABC.0' becomes source '/data/dbfast1/demoDataDir0'
func ResetPgUpgradeCommand ¶
func ResetPgUpgradeCommand()
func ResetRemoteVersionCommand ¶
func ResetRemoteVersionCommand()
func RestorePgControl ¶
func RestorePgControl(dataDir string, streams step.OutStreams) error
RestorePgControl renames pg_control.old to pg_control so that the coordinator and segments can start after pg_upgrade is run in link mode. The dir passed to RestorePgControl must be a data directory. It is idempotent as it already checks if the rename has occurred.
func SetLocalVersionCommand ¶
XXX: for internal testing only
func SetPgUpgradeCommand ¶
func SetRemoteVersionCommand ¶
func TablespacePath ¶
func TempDataDir ¶
TempDataDir transforms a data directory into a corresponding temporary path suitable for an upgrade target, using the desired cluster segment prefix and upgrade ID for uniqification.
The rules are currently as follows due to 6X gpinitsystem requirements:
- The temporary datadir will be placed next to the original datadir.
- If the datadir basename starts with the segment prefix, the remainder of the basename is considered the segment suffix. The temporary datadir will also start with the segment prefix and end with the segment suffix.
- If the datadir basename does not start with the segment prefix (as can happen with e.g. standby data directories), the temporary datadir will start with the original basename.
func VerifyDataDirectory ¶
func VerifyLegacyTablespaceDbOIDDirectory ¶
VerifyLegacyTablespaceDbOIDDirectory verifies a directory for GPDB 5X and lower. It takes an input path of /dir/<fsname>/<datadir>/<tablespaceOID>/<dbOID> and checks if the underlying relfilenode directory contains the PG_VERSION file. Note that the input path is one level down from the tablespace location. No error is returned when the dbOid directory does not exist since the user may not have created a table within the tablespace. The expected tablespace directory layout is: /dir/<fsname>/<datadir>/<tablespaceOID>/<dbOID>/<relfilenode>
func VerifyTablespaceDbIDDirectory ¶
VerifyTablespaceDbIDDirectory verifies a directory for GPDB 6X and higher. It takes an input path of the form /dir/<fsname>/<datadir>/<tablespaceOID>/<dbID> and checks if the underlying directory starts with "GPDB_". Note that the input path is one level down from the tablespace location. The expected tablespace directory layout is: /dir/<fsname>/<datadir>/<tablespaceOID>/<dbID>/GPDB_6_<catalogVersion>/<dbOID>/<relfilenode>
func VerifyTablespaceDirectory ¶
VerifyTablespaceDirectory verifies directories for GPDB 6X and higher. It takes an input path of the form /dir/<fsname>/<datadir>/<tablespaceOID>/<dbID> and checks if the underlying directory starts with "GPDB_". Note that the input path is one level down from the tablespace location. The expected tablespace directory layout is: /dir/<fsname>/<datadir>/<tablespaceOID>/<dbID>/GPDB_6_<catalogVersion>/<dbOID>/<relfilenode>
func VerifyTablespaceLocation ¶
VerifyTablespaceLocation verifies if the given path is either a tablespace (ie: 6X and higher), or legacy (ie: 5X) tablespace location. The input path is a tablespace location with the form /dir/<fsname>/<datadir>/<tablespaceOID>
Types ¶
type InvalidDataDirectoryError ¶
type InvalidDataDirectoryError struct {
// contains filtered or unexported fields
}
InvalidDataDirectoryError is the backing error type for ErrInvalidDataDirectory.
func (*InvalidDataDirectoryError) Error ¶
func (i *InvalidDataDirectoryError) Error() string
func (*InvalidDataDirectoryError) Is ¶
func (i *InvalidDataDirectoryError) Is(err error) bool
type MismatchedVersions ¶
func (MismatchedVersions) String ¶
func (m MismatchedVersions) String() string