Skip to content

Commit

Permalink
hotfix 2.2.8, fix #676 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slach committed Jun 26, 2023
1 parent e512faa commit f5b2196
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 17 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.2.8
BUG FIXES
- hotfix wrong empty files when disk_mapping contains not exists during create, affected 2.2.7 version, look details [676](https://github.com/Altinity/clickhouse-backup/issues/676#issue-1771732489)

# v2.2.7
IMPROVEMENTS
- Auto-tuning concurrency and buffer size related parameters depending on remote storage type, fix [658](https://github.com/AlexAkulov/clickhouse-backup/issues/658)
Expand Down
2 changes: 1 addition & 1 deletion pkg/backup/backuper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewBackuper(cfg *config.Config) *Backuper {
func (b *Backuper) init(ctx context.Context, disks []clickhouse.Disk, backupName string) error {
var err error
if disks == nil {
disks, err = b.ch.GetDisks(ctx)
disks, err = b.ch.GetDisks(ctx, true)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/backup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (b *Backuper) CreateBackup(backupName, tablePattern string, partitions []st
return fmt.Errorf("GetUserDefinedFunctions return error: %v", err)
}

disks, err := b.ch.GetDisks(ctx)
disks, err := b.ch.GetDisks(ctx, false)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/backup/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (b *Backuper) Clean(ctx context.Context) error {
}
defer b.ch.Close()

disks, err := b.ch.GetDisks(ctx)
disks, err := b.ch.GetDisks(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (b *Backuper) RemoveBackupLocal(ctx context.Context, backupName string, dis
}
defer b.ch.Close()
if disks == nil {
disks, err = b.ch.GetDisks(ctx)
disks, err = b.ch.GetDisks(ctx, true)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/backup/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (b *Backuper) GetLocalBackups(ctx context.Context, disks []clickhouse.Disk)
}
log := b.log.WithField("logger", "GetLocalBackups")
if disks == nil {
disks, err = b.ch.GetDisks(ctx)
disks, err = b.ch.GetDisks(ctx, true)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -397,7 +397,7 @@ func (b *Backuper) PrintTables(printAll bool, tablePattern string) error {
if err != nil {
return err
}
disks, err := b.ch.GetDisks(ctx)
disks, err := b.ch.GetDisks(ctx, false)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/backup/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (b *Backuper) Restore(backupName, tablePattern string, databaseMapping, par
_ = b.PrintLocalBackups(ctx, "all")
return fmt.Errorf("select backup for restore")
}
disks, err := b.ch.GetDisks(ctx)
disks, err := b.ch.GetDisks(ctx, true)
if err != nil {
return err
}
Expand Down
18 changes: 10 additions & 8 deletions pkg/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (ch *ClickHouse) Connect() error {
}

// GetDisks - return data from system.disks table
func (ch *ClickHouse) GetDisks(ctx context.Context) ([]Disk, error) {
func (ch *ClickHouse) GetDisks(ctx context.Context, enrich bool) ([]Disk, error) {
version, err := ch.GetVersion(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -164,12 +164,14 @@ func (ch *ClickHouse) GetDisks(ctx context.Context) ([]Disk, error) {
delete(dm, disks[i].Name)
}
}
for k, v := range dm {
disks = append(disks, Disk{
Name: k,
Path: v,
Type: "local",
})
if enrich {
for k, v := range dm {
disks = append(disks, Disk{
Name: k,
Path: v,
Type: "local",
})
}
}
return disks, nil
}
Expand Down Expand Up @@ -1018,7 +1020,7 @@ func (ch *ClickHouse) GetAccessManagementPath(ctx context.Context, disks []Disk)
var rows []string
if err := ch.SelectContext(ctx, &rows, "SELECT JSONExtractString(params,'path') AS access_path FROM system.user_directories WHERE type='local directory'"); err != nil || len(rows) == 0 {
if disks == nil {
disks, err = ch.GetDisks(ctx)
disks, err = ch.GetDisks(ctx, false)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ func (api *APIServer) ResumeOperationsAfterRestart() error {
api.log.Errorf("ResumeOperationsAfterRestart can't close clickhouse connection: %v", err)
}
}()
disks, err := ch.GetDisks(context.Background())
disks, err := ch.GetDisks(context.Background(), true)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion test/integration/config-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ general:
- "_temporary_and_external_tables.*"
restore_schema_on_cluster: "{cluster}"
clickhouse:
# wrong disk name mapping for https://github.com/Altinity/clickhouse-backup/issues/676
disk_mapping:
default-gp3: /var/lib/clickhouse
host: 127.0.0.1
port: 9440
username: backup
password: meow=& 123?*%# МЯУ
secure: true
skip_verify: true
sync_replicated_tables: true
timeout: 1s
timeout: 2s
restart_command: bash -c 'echo "FAKE RESTART"'
backup_mutations: true
s3:
Expand Down

0 comments on commit f5b2196

Please sign in to comment.