upgrade

package
v0.0.0-...-31509f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAgentPort = 6416
View Source
const DefaultDynamicLibraryPath = "$libdir"
View Source
const DefaultHubPort = 7527
View Source
const OldSuffix = ".old"
View Source
const PGVersion = "PG_VERSION"

Variables

View Source
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.

View Source
var PostgresFiles = []string{"postgresql.conf", PGVersion}
View Source
var StateDirectoryFiles = []string{"config.json", step.SubstepsFileName}

Functions

func AlreadyRenamed

func AlreadyRenamed(src, dst string) (bool, error)

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 EnsureGpupgradeVersionsMatch

func EnsureGpupgradeVersionsMatch(agentHosts []string) error

func LocalVersion

func LocalVersion() (string, error)

func NewID

func NewID() string

NewID creates a new unique upgrade ID that is reasonably unique across executions of the process.

func PathExist

func PathExist(path string) (bool, error)

func PathExistInFS

func PathExistInFS(fsys fs.FS, path string) (bool, error)

func RemoteVersion

func RemoteVersion(host string) (string, error)

func RenameDirectories

func RenameDirectories(source, target string) error

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 ResetLocalVersionCommand

func ResetLocalVersionCommand()

XXX: for internal testing only

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 Run

func Run(stdout, stderr io.Writer, opts *idl.PgOptions) error

func SetLocalVersionCommand

func SetLocalVersionCommand(command exectest.Command)

XXX: for internal testing only

func SetPgUpgradeCommand

func SetPgUpgradeCommand(cmdFunc exectest.Command)

func SetRemoteVersionCommand

func SetRemoteVersionCommand(command exectest.Command)

func TablespacePath

func TablespacePath(tablespaceLocation string, dbID int32, majorVersion uint64, catalogVersion string) string

func TempDataDir

func TempDataDir(datadir, segPrefix string, upgradeID string) string

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 VerifyDataDirectory(path ...string) error

func VerifyLegacyTablespaceDbOIDDirectory

func VerifyLegacyTablespaceDbOIDDirectory(fsys fs.FS, dbOID string) (bool, error)

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

func VerifyTablespaceDbIDDirectory(fsys fs.FS, dbID string) (bool, error)

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

func VerifyTablespaceDirectory(path string) (bool, error)

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

func VerifyTablespaceLocation(fsys fs.FS, tsLocation string) error

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

type MismatchedVersions

type MismatchedVersions map[string][]string

func (MismatchedVersions) String

func (m MismatchedVersions) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL