Skip to content

Commit 7b57df8

Browse files
Merge pull request #1084 from percona/PBM-14780-pbm-backup-does-not-work-with-single-cpu
PBM-14780 Adjust concurrentCollections for backup operation for single CPU
2 parents a0ed86d + 9dd787c commit 7b57df8

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cmd/pbm-agent/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func setRootFlags(rootCmd *cobra.Command) {
101101
rootCmd.Flags().Int("dump-parallel-collections", 0, "Number of collections to dump in parallel")
102102
_ = viper.BindPFlag("backup.dump-parallel-collections", rootCmd.Flags().Lookup("dump-parallel-collections"))
103103
_ = viper.BindEnv("backup.dump-parallel-collections", "PBM_DUMP_PARALLEL_COLLECTIONS")
104-
viper.SetDefault("backup.dump-parallel-collections", runtime.NumCPU()/2)
104+
viper.SetDefault("backup.dump-parallel-collections", max(runtime.NumCPU()/2, 1))
105105

106106
rootCmd.Flags().String("log-path", "", "Path to file")
107107
_ = viper.BindPFlag("log.path", rootCmd.Flags().Lookup("log-path"))

pbm/archive/backup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func NewBackup(ctx context.Context, options BackupOptions) (*backupImpl, error)
105105
newFile: options.NewFile,
106106
nsFilter: DefaultNSFilter,
107107
docFilter: DefaultDocFilter,
108-
concurrency: runtime.NumCPU() / 2,
108+
concurrency: max(runtime.NumCPU()/2, 1),
109109
}
110110

111111
if options.NSFilter != nil {

pbm/archive/conv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func GenerateV1FromV2(ctx context.Context, stg storage.Storage, bcp, rs string)
6262
func convertMetaToV1(metaV2 *ArchiveMetaV2) (*archiveMeta, error) {
6363
metaV1 := &archiveMeta{
6464
Header: &mtArchive.Header{
65-
ConcurrentCollections: int32(runtime.NumCPU() / 2),
65+
ConcurrentCollections: int32(max(runtime.NumCPU()/2, 1)),
6666

6767
FormatVersion: "0.1",
6868
ServerVersion: metaV2.ServerVersion,

0 commit comments

Comments
 (0)