Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADBDEV-6599: Make gprestore --resize-cluster use --jobs for parallel restoration #110

Merged
merged 78 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
ca1c1db
Implement MVP to paralellize gprestore
RekGRpth Oct 1, 2024
e8b6c1a
fix test
RekGRpth Oct 1, 2024
fffe562
fix backup and tests
RekGRpth Oct 1, 2024
3c0a096
optimize
RekGRpth Oct 1, 2024
ee14bef
test
RekGRpth Oct 1, 2024
733e6a6
fix
RekGRpth Oct 1, 2024
4f8a3ac
fix
RekGRpth Oct 1, 2024
971d5ea
simplify
RekGRpth Oct 1, 2024
873b43b
simplify
RekGRpth Oct 3, 2024
f1e5832
rename
RekGRpth Oct 3, 2024
6b56776
rename
RekGRpth Oct 3, 2024
70940ca
rename
RekGRpth Oct 3, 2024
6f575f6
format
RekGRpth Oct 3, 2024
b164a27
Merge branch 'master' into ADBDEV-6338
RekGRpth Oct 4, 2024
b6b1705
Merge branch 'master' into ADBDEV-6599
RekGRpth Oct 29, 2024
2476483
test
RekGRpth Oct 29, 2024
39cf460
comment
RekGRpth Oct 29, 2024
defe56a
optimize
RekGRpth Oct 30, 2024
163d2b4
stabelize tests
RekGRpth Oct 30, 2024
1a5aacc
fix
RekGRpth Oct 30, 2024
24af8f7
fix
RekGRpth Oct 31, 2024
6053237
revert
RekGRpth Oct 31, 2024
a1d7df5
Merge branch 'master' into ADBDEV-6599
RekGRpth Nov 11, 2024
649935a
fix test
RekGRpth Nov 12, 2024
54dbb1f
stabellize test
RekGRpth Nov 12, 2024
5265dd3
Merge branch 'master' into ADBDEV-6599
RekGRpth Dec 3, 2024
7e47f64
add helper index
RekGRpth Dec 3, 2024
867c9b8
-step
RekGRpth Dec 3, 2024
015c646
fix test
RekGRpth Dec 4, 2024
a654b57
optimize
RekGRpth Dec 4, 2024
2644704
revert backup
RekGRpth Dec 4, 2024
4526c83
simplify and optimize
RekGRpth Dec 4, 2024
7203cec
fix
RekGRpth Dec 4, 2024
c352e26
simplify
RekGRpth Dec 4, 2024
62044ca
skip
RekGRpth Dec 4, 2024
c9e3949
error
RekGRpth Dec 4, 2024
0a45237
rename
RekGRpth Dec 4, 2024
5a486a3
mv
RekGRpth Dec 4, 2024
61ffe30
rename
RekGRpth Dec 4, 2024
6d47183
simplify
RekGRpth Dec 4, 2024
fdb18a4
simplify
RekGRpth Dec 4, 2024
11a1244
fix
RekGRpth Dec 4, 2024
a45a360
simplify
RekGRpth Dec 4, 2024
932f382
simplify
RekGRpth Dec 4, 2024
846efcb
simplify
RekGRpth Dec 4, 2024
473f790
simplify
RekGRpth Dec 4, 2024
e822f56
pipe
RekGRpth Dec 4, 2024
1c5a445
fix test
RekGRpth Dec 4, 2024
a6dc131
simplify
RekGRpth Dec 4, 2024
26c93c3
fix
RekGRpth Dec 4, 2024
a257cef
error
RekGRpth Dec 4, 2024
600a752
fix test
RekGRpth Dec 4, 2024
bcba70a
fix test
RekGRpth Dec 4, 2024
d0fedbb
fix tests
RekGRpth Dec 4, 2024
9c13069
fix test
RekGRpth Dec 4, 2024
a7b37c1
error
RekGRpth Dec 4, 2024
0ac6864
fix
RekGRpth Dec 4, 2024
3988ff5
rename
RekGRpth Dec 4, 2024
0a18bad
fix tests
RekGRpth Dec 4, 2024
ba750c4
error
RekGRpth Dec 4, 2024
1caa858
fix
RekGRpth Dec 4, 2024
d8a1ebe
fix test
RekGRpth Dec 4, 2024
8de1a68
fix test
RekGRpth Dec 4, 2024
39a7a3a
fix test
RekGRpth Dec 4, 2024
c91309b
optimize
RekGRpth Dec 4, 2024
91484d2
simplify
RekGRpth Dec 4, 2024
f519803
fix test
RekGRpth Dec 4, 2024
4a11b18
skip
RekGRpth Dec 4, 2024
f590f04
skip
RekGRpth Dec 4, 2024
62a0bd6
error
RekGRpth Dec 5, 2024
b9543d8
test
RekGRpth Dec 5, 2024
5e4a44c
Merge branch 'master' into ADBDEV-6599
RekGRpth Dec 5, 2024
8dd19ca
max helpers
RekGRpth Dec 6, 2024
f94440f
fix
RekGRpth Dec 6, 2024
6956a93
fatal when ivalid
RekGRpth Dec 6, 2024
fa6222e
optimize
RekGRpth Dec 6, 2024
04d77da
replace last only
RekGRpth Dec 6, 2024
9a4a45c
fix
RekGRpth Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ func backupData(tables []Table) {
for _, table := range tables {
oidList = append(oidList, fmt.Sprintf("%d", table.Oid))
}
utils.WriteOidListToSegments(oidList, globalCluster, globalFPInfo, "oid")
utils.WriteOidListToSegments(oidList, globalCluster, globalFPInfo, "oid_0")
compressStr := fmt.Sprintf(" --compression-level %d --compression-type %s", MustGetFlagInt(options.COMPRESSION_LEVEL), MustGetFlagString(options.COMPRESSION_TYPE))
if MustGetFlagBool(options.NO_COMPRESSION) {
compressStr = " --compression-level 0"
}
initialPipes := CreateInitialSegmentPipes(oidList, globalCluster, connectionPool, globalFPInfo)
// Do not pass through the --on-error-continue flag or the resizeClusterMap because neither apply to gpbackup
utils.StartGpbackupHelpers(globalCluster, globalFPInfo, "--backup-agent",
MustGetFlagString(options.PLUGIN_CONFIG), compressStr, false, false, &wasTerminated, initialPipes, true, false, 0, 0, gplog.GetVerbosity())
MustGetFlagString(options.PLUGIN_CONFIG), compressStr, false, false, &wasTerminated, initialPipes, true, false, 0, 0, gplog.GetVerbosity(), 0)
}
gplog.Info("Writing data to file")
rowsCopiedMaps := BackupDataForAllTables(tables)
Expand Down
94 changes: 71 additions & 23 deletions end_to_end/end_to_end_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func assertArtifactsCleaned(timestamp string) {
scriptFile := fpInfo.GetSegmentHelperFilePath(contentID, "script")
pipeFile := fpInfo.GetSegmentPipeFilePath(contentID)

return fmt.Sprintf("! ls %s && ! ls %s && ! ls %s && ! ls %s*", errorFile, oidFile, scriptFile, pipeFile)
return fmt.Sprintf("! ls %s && ! ls %s* && ! ls %s* && ! ls %s*", errorFile, oidFile, scriptFile, pipeFile)
}
remoteOutput := backupCluster.GenerateAndExecuteCommand(description, cluster.ON_SEGMENTS|cluster.INCLUDE_COORDINATOR, cleanupFunc)
if remoteOutput.NumErrors != 0 {
Expand Down Expand Up @@ -2326,7 +2326,7 @@ LANGUAGE plpgsql NO SQL;`)
testhelper.AssertQueryRuns(restoreConn, "DROP ROLE testrole;")
})
DescribeTable("",
func(fullTimestamp string, incrementalTimestamp string, tarBaseName string, isIncrementalRestore bool, isFilteredRestore bool, isSingleDataFileRestore bool, testUsesPlugin bool) {
func(fullTimestamp string, incrementalTimestamp string, tarBaseName string, isIncrementalRestore bool, isFilteredRestore bool, isSingleDataFileRestore bool, testUsesPlugin bool, size int) {
if isSingleDataFileRestore && segmentCount != 3 {
Skip("Single data file resize restores currently require a 3-segment cluster to test.")
}
Expand Down Expand Up @@ -2358,6 +2358,13 @@ LANGUAGE plpgsql NO SQL;`)
if isFilteredRestore {
gprestoreArgs = append(gprestoreArgs, "--include-schema", "schematwo")
}
if size > 1 {
if isSingleDataFileRestore {
gprestoreArgs = append(gprestoreArgs, "--copy-queue-size", fmt.Sprintf("%d", size))
} else {
gprestoreArgs = append(gprestoreArgs, "--jobs", fmt.Sprintf("%d", size))
}
}
gprestore(gprestorePath, restoreHelperPath, fullTimestamp, gprestoreArgs...)

// check row counts
Expand Down Expand Up @@ -2404,31 +2411,57 @@ LANGUAGE plpgsql NO SQL;`)
}
}
},
Entry("Can backup a 9-segment cluster and restore to current cluster", "20220909090738", "", "9-segment-db", false, false, false, false),
Entry("Can backup a 9-segment cluster and restore to current cluster with single data file", "20220909090827", "", "9-segment-db-single-data-file", false, false, true, false),
Entry("Can backup a 9-segment cluster and restore to current cluster with incremental backups", "20220909150254", "20220909150353", "9-segment-db-incremental", true, false, false, false),

Entry("Can backup a 7-segment cluster and restore to current cluster", "20220908145504", "", "7-segment-db", false, false, false, false),
Entry("Can backup a 7-segment cluster and restore to current cluster single data file", "20220912101931", "", "7-segment-db-single-data-file", false, false, true, false),
Entry("Can backup a 7-segment cluster and restore to current cluster with a filter", "20220908145645", "", "7-segment-db-filter", false, true, false, false),
Entry("Can backup a 7-segment cluster and restore to current cluster with single data file and filter", "20220912102413", "", "7-segment-db-single-data-file-filter", false, true, true, false),
Entry("Can backup a 2-segment cluster and restore to current cluster single data file and filter", "20220908150223", "", "2-segment-db-single-data-file-filter", false, true, true, false),
Entry("Can backup a 2-segment cluster and restore to current cluster single data file", "20220908150159", "", "2-segment-db-single-data-file", false, false, true, false),
Entry("Can backup a 2-segment cluster and restore to current cluster with filter", "20220908150238", "", "2-segment-db-filter", false, true, false, false),
Entry("Can backup a 2-segment cluster and restore to current cluster with incremental backups and a single data file", "20220909150612", "20220909150622", "2-segment-db-incremental", true, false, false, false),
Entry("Can backup a 1-segment cluster and restore to current cluster", "20220908150735", "", "1-segment-db", false, false, false, false),
Entry("Can backup a 1-segment cluster and restore to current cluster with single data file", "20220908150752", "", "1-segment-db-single-data-file", false, false, true, false),
Entry("Can backup a 1-segment cluster and restore to current cluster with a filter", "20220908150804", "", "1-segment-db-filter", false, true, false, false),
Entry("Can backup a 3-segment cluster and restore to current cluster", "20220909094828", "", "3-segment-db", false, false, false, false),

Entry("Can backup a 2-segment using gpbackup 1.26.0 and restore to current cluster", "20230516032007", "", "2-segment-db-1_26_0", false, false, false, false),
Entry("Can backup a 9-segment cluster and restore to current cluster", "20220909090738", "", "9-segment-db", false, false, false, false, 1),
Entry("Can backup a 9-segment cluster and restore to current cluster with single data file", "20220909090827", "", "9-segment-db-single-data-file", false, false, true, false, 1),
Entry("Can backup a 9-segment cluster and restore to current cluster with incremental backups", "20220909150254", "20220909150353", "9-segment-db-incremental", true, false, false, false, 1),

Entry("Can backup a 7-segment cluster and restore to current cluster", "20220908145504", "", "7-segment-db", false, false, false, false, 1),
Entry("Can backup a 7-segment cluster and restore to current cluster single data file", "20220912101931", "", "7-segment-db-single-data-file", false, false, true, false, 1),
Entry("Can backup a 7-segment cluster and restore to current cluster with a filter", "20220908145645", "", "7-segment-db-filter", false, true, false, false, 1),
Entry("Can backup a 7-segment cluster and restore to current cluster with single data file and filter", "20220912102413", "", "7-segment-db-single-data-file-filter", false, true, true, false, 1),
Entry("Can backup a 2-segment cluster and restore to current cluster single data file and filter", "20220908150223", "", "2-segment-db-single-data-file-filter", false, true, true, false, 1),
Entry("Can backup a 2-segment cluster and restore to current cluster single data file", "20220908150159", "", "2-segment-db-single-data-file", false, false, true, false, 1),
Entry("Can backup a 2-segment cluster and restore to current cluster with filter", "20220908150238", "", "2-segment-db-filter", false, true, false, false, 1),
Entry("Can backup a 2-segment cluster and restore to current cluster with incremental backups and a single data file", "20220909150612", "20220909150622", "2-segment-db-incremental", true, false, true, false, 1),
Entry("Can backup a 1-segment cluster and restore to current cluster", "20220908150735", "", "1-segment-db", false, false, false, false, 1),
Entry("Can backup a 1-segment cluster and restore to current cluster with single data file", "20220908150752", "", "1-segment-db-single-data-file", false, false, true, false, 1),
Entry("Can backup a 1-segment cluster and restore to current cluster with a filter", "20220908150804", "", "1-segment-db-filter", false, true, false, false, 1),
Entry("Can backup a 3-segment cluster and restore to current cluster", "20220909094828", "", "3-segment-db", false, false, false, false, 1),

Entry("Can backup a 2-segment using gpbackup 1.26.0 and restore to current cluster", "20230516032007", "", "2-segment-db-1_26_0", false, false, false, false, 1),

// These tests will only run in CI, to avoid requiring developers to configure a plugin locally.
// We don't do as many combinatoric tests for resize restores using plugins, partly for storage space reasons and partly because
// we assume that if all of the above resize restores work and basic plugin restores work then the intersection should also work.
Entry("Can perform a backup and full restore of a 7-segment cluster using a plugin", "20220912101931", "", "7-segment-db-single-data-file", false, false, true, true, 1),
Entry("Can perform a backup and full restore of a 2-segment cluster using a plugin", "20220908150159", "", "2-segment-db-single-data-file", false, false, true, true, 1),
Entry("Can perform a backup and incremental restore of a 2-segment cluster using a plugin", "20220909150612", "20220909150622", "2-segment-db-incremental", true, false, false, true, 1),

Entry("Can backup a 9-segment cluster and restore to current cluster with jobs", "20220909090738", "", "9-segment-db", false, false, false, false, 3),
Entry("Can backup a 9-segment cluster and restore to current cluster with single data file with copy-queue-size", "20220909090827", "", "9-segment-db-single-data-file", false, false, true, false, 3),
Entry("Can backup a 9-segment cluster and restore to current cluster with incremental backups with jobs", "20220909150254", "20220909150353", "9-segment-db-incremental", true, false, false, false, 3),

Entry("Can backup a 7-segment cluster and restore to current cluster with jobs", "20220908145504", "", "7-segment-db", false, false, false, false, 3),
Entry("Can backup a 7-segment cluster and restore to current cluster single data file with copy-queue-size", "20220912101931", "", "7-segment-db-single-data-file", false, false, true, false, 3),
Entry("Can backup a 7-segment cluster and restore to current cluster with a filter with jobs", "20220908145645", "", "7-segment-db-filter", false, true, false, false, 3),
Entry("Can backup a 7-segment cluster and restore to current cluster with single data file and filter with copy-queue-size", "20220912102413", "", "7-segment-db-single-data-file-filter", false, true, true, false, 3),
Entry("Can backup a 2-segment cluster and restore to current cluster single data file and filter with copy-queue-size", "20220908150223", "", "2-segment-db-single-data-file-filter", false, true, true, false, 3),
Entry("Can backup a 2-segment cluster and restore to current cluster single data file with copy-queue-size", "20220908150159", "", "2-segment-db-single-data-file", false, false, true, false, 3),
Entry("Can backup a 2-segment cluster and restore to current cluster with filter with jobs", "20220908150238", "", "2-segment-db-filter", false, true, false, false, 3),
Entry("Can backup a 2-segment cluster and restore to current cluster with incremental backups and a single data file with copy-queue-size", "20220909150612", "20220909150622", "2-segment-db-incremental", true, false, true, false, 3),
Entry("Can backup a 1-segment cluster and restore to current cluster with jobs", "20220908150735", "", "1-segment-db", false, false, false, false, 3),
Entry("Can backup a 1-segment cluster and restore to current cluster with single data file with copy-queue-size", "20220908150752", "", "1-segment-db-single-data-file", false, false, true, false, 3),
Entry("Can backup a 1-segment cluster and restore to current cluster with a filter with jobs", "20220908150804", "", "1-segment-db-filter", false, true, false, false, 3),
Entry("Can backup a 3-segment cluster and restore to current cluster with jobs", "20220909094828", "", "3-segment-db", false, false, false, false, 3),

Entry("Can backup a 2-segment using gpbackup 1.26.0 and restore to current cluster with jobs", "20230516032007", "", "2-segment-db-1_26_0", false, false, false, false, 3),

// These tests will only run in CI, to avoid requiring developers to configure a plugin locally.
// We don't do as many combinatoric tests for resize restores using plugins, partly for storage space reasons and partly because
// we assume that if all of the above resize restores work and basic plugin restores work then the intersection should also work.
Entry("Can perform a backup and full restore of a 7-segment cluster using a plugin", "20220912101931", "", "7-segment-db-single-data-file", false, false, true, true),
Entry("Can perform a backup and full restore of a 2-segment cluster using a plugin", "20220908150159", "", "2-segment-db-single-data-file", false, false, true, true),
Entry("Can perform a backup and incremental restore of a 2-segment cluster using a plugin", "20220909150612", "20220909150622", "2-segment-db-incremental", true, false, false, true),
Entry("Can perform a backup and full restore of a 7-segment cluster using a plugin with jobs", "20220912101931", "", "7-segment-db-single-data-file", false, false, true, true, 3),
Entry("Can perform a backup and full restore of a 2-segment cluster using a plugin with jobs", "20220908150159", "", "2-segment-db-single-data-file", false, false, true, true, 3),
Entry("Can perform a backup and incremental restore of a 2-segment cluster using a plugin with jobs", "20220909150612", "20220909150622", "2-segment-db-incremental", true, false, false, true, 3),
)
It("will not restore a pre-1.26.0 backup that lacks a stored SegmentCount value", func() {
extractDirectory := extractSavedTarFile(backupDir, "2-segment-db-1_24_0")
Expand Down Expand Up @@ -2584,6 +2617,21 @@ LANGUAGE plpgsql NO SQL;`)
assertArtifactsCleaned("20240502095933")
testhelper.AssertQueryRuns(restoreConn, "DROP TABLE t0; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4;")
})
It("Will continue after error during restore with jobs", func() {
command := exec.Command("tar", "-xzf", "resources/2-segment-db-error.tar.gz", "-C", backupDir)
mustRunCommand(command)
gprestoreCmd := exec.Command(gprestorePath,
"--timestamp", "20240502095933",
"--redirect-db", "restoredb",
"--backup-dir", path.Join(backupDir, "2-segment-db-error"),
"--resize-cluster", "--jobs", "3", "--on-error-continue")
output, err := gprestoreCmd.CombinedOutput()
Expect(err).To(HaveOccurred())
Expect(string(output)).To(ContainSubstring(`Error loading data into table public.t1`))
Expect(string(output)).ToNot(ContainSubstring(`Error loading data into table public.t2`))
assertArtifactsCleaned("20240502095933")
testhelper.AssertQueryRuns(restoreConn, "DROP TABLE t0; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4;")
})
It("Will not hang after error during single data file restore", func() {
command := exec.Command("tar", "-xzf", "resources/3-segment-db-single-data-file.tar.gz", "-C", backupDir)
mustRunCommand(command)
Expand Down
6 changes: 3 additions & 3 deletions integration/agent_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ var _ = Describe("agent remote", func() {
})
Describe("WriteOidListToSegments()", func() {
It("writes oids to a temp file and copies it to all segments", func() {
utils.WriteOidListToSegments(oidList, testCluster, filePath, "oid")
utils.WriteOidListToSegments(oidList, testCluster, filePath, "oid_0")

remoteOutput := testCluster.GenerateAndExecuteCommand("ensure oid file was written to segments", cluster.ON_SEGMENTS, func(contentID int) string {
remoteOidFile := filePath.GetSegmentHelperFilePath(contentID, "oid")
remoteOidFile := filePath.GetSegmentHelperFilePath(contentID, "oid_0")
return fmt.Sprintf("cat %s", remoteOidFile)
})
defer func() {
remoteOutputRemoval := testCluster.GenerateAndExecuteCommand("ensure oid file removed", cluster.ON_SEGMENTS, func(contentID int) string {
remoteOidFile := filePath.GetSegmentHelperFilePath(contentID, "oid")
remoteOidFile := filePath.GetSegmentHelperFilePath(contentID, "oid_0")
return fmt.Sprintf("rm %s", remoteOidFile)
})
testCluster.CheckClusterError(remoteOutputRemoval, "Could not remove oid file", func(contentID int) string {
Expand Down
Loading
Loading