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

[WIP] try switch to Zerolog #670

Merged
merged 23 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d0f5b19
migrate from `apex/log` to `rs/zerolog`, fix RaceConditions, fix http…
Slach Jun 12, 2023
0562dd0
fix thread-safe zerolog usage, details https://github.com/rs/zerolog/…
Slach Jun 13, 2023
e1ca361
fix thread-safe zerolog usage, details https://github.com/rs/zerolog/…
Slach Jun 13, 2023
8b96079
fix thread-safe zerolog usage, details https://github.com/rs/zerolog/…
Slach Jun 13, 2023
daa39d3
fix thread-safe zerolog usage, details https://github.com/rs/zerolog/…
Slach Jun 13, 2023
afc1111
fix thread-safe zerolog usage, try to remove diode, details https://g…
Slach Jun 13, 2023
79910c1
fix thread-safe zerolog usage, try to remove consoleWriter, details h…
Slach Jun 13, 2023
b1507c0
fix thread-safe zerolog usage, try to add zerolog.SyncWriter, details…
Slach Jun 13, 2023
907377c
debug thread-safe zerolog usage, https://github.com/rs/zerolog/issues…
Slach Jun 13, 2023
733e689
debug thread-safe zerolog usage, https://github.com/rs/zerolog/issues…
Slach Jun 14, 2023
fd90f25
debug thread-safe zerolog usage, https://github.com/rs/zerolog/issues…
Slach Jun 14, 2023
eea4f62
zerolog completelly useless for multiple go-routines ;( https://githu…
Slach Jun 14, 2023
98245c3
apply fixes from https://github.com/rs/zerolog/issues/555#issuecommen…
Slach Aug 12, 2023
002004e
fixes for test
Slach Aug 13, 2023
b9cba9d
Merge branch 'master' of github.com:Altinity/clickhouse-backup into z…
Slach Aug 13, 2023
2d000c5
try debug zerolog race condition https://github.com/rs/zerolog/issues…
Slach Aug 13, 2023
0298ea1
switch to golang 1.21
Slach Aug 13, 2023
2251da9
try to apply workaround to avoid race-condtions, https://github.com/A…
Slach Aug 2, 2024
b8b1c66
trigger zerolog branch build
Slach Aug 2, 2024
1d10034
trigger zerolog branch build
Slach Aug 2, 2024
8e963d1
trigger zerolog branch build
Slach Aug 2, 2024
c8dd9a0
Merge branch 'master' of github.com:Altinity/clickhouse-backup into z…
Slach Aug 3, 2024
a26d40a
improve build.yaml to avoid double trigger
Slach Aug 3, 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 .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Build
on:
pull_request:
branches:
- master
- "*"

push:
branches:
- "*"
- master

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ IMPROVEMENTS
- improve support for `use_embedded_backup_restore: true`, applied ugly workaround in test to avoid https://github.com/ClickHouse/ClickHouse/issues/43971, and applied restore workaround to resolve https://github.com/ClickHouse/ClickHouse/issues/42709
- migrate to `clickhouse-go/v2`, fix [540](https://github.com/Altinity/clickhouse-backup/issues/540), close [562](https://github.com/Altinity/clickhouse-backup/pull/562)
- add documentation for `AWS_ARN_ROLE` and `AWS_WEB_IDENTITY_TOKEN_FILE`, fix [563](https://github.com/Altinity/clickhouse-backup/issues/563)
- migrate from `apex/log` to `rs/zerolog`, fix RaceConditions, fix [624](https://github.com/Altinity/clickhouse-backup/issues/624),see details https://github.com/apex/log/issues/103

BUG FIXES
- hotfix wrong empty files when disk_mapping contains don't exist during creation, affected 2.2.7 version, look details [676](https://github.com/Altinity/clickhouse-backup/issues/676#issue-1771732489)
Expand Down
23 changes: 17 additions & 6 deletions cmd/clickhouse-backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package main
import (
"context"
"fmt"
stdlog "log"
"os"
"strings"

"github.com/apex/log"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
"github.com/urfave/cli"

"github.com/Altinity/clickhouse-backup/v2/pkg/backup"
"github.com/Altinity/clickhouse-backup/v2/pkg/config"
"github.com/Altinity/clickhouse-backup/v2/pkg/logcli"
"github.com/Altinity/clickhouse-backup/v2/pkg/server"
"github.com/Altinity/clickhouse-backup/v2/pkg/status"
)
Expand All @@ -23,7 +25,16 @@ var (
)

func main() {
log.SetHandler(logcli.New(os.Stderr))
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
consoleWriter := zerolog.ConsoleWriter{Out: os.Stderr, NoColor: true, TimeFormat: "2006-01-02 15:04:05.000"}
//diodeWriter := diode.NewWriter(consoleWriter, 4096, 10*time.Millisecond, func(missed int) {
// fmt.Printf("Logger Dropped %d messages", missed)
//})
log.Logger = zerolog.New(zerolog.SyncWriter(consoleWriter)).With().Timestamp().Caller().Logger()
//zerolog.SetGlobalLevel(zerolog.Disabled)
//log.Logger = zerolog.New(os.Stdout).With().Timestamp().Caller().Logger()
stdlog.SetOutput(log.Logger)
cliapp := cli.NewApp()
cliapp.Name = "clickhouse-backup"
cliapp.Usage = "Tool for easy backup of ClickHouse with cloud support"
Expand Down Expand Up @@ -499,11 +510,11 @@ func main() {
Action: func(c *cli.Context) error {
b := backup.NewBackuper(config.GetConfigFromCli(c))
if c.Args().Get(1) == "" {
log.Errorf("Backup name must be defined")
log.Err(fmt.Errorf("backup name must be defined")).Send()
cli.ShowCommandHelpAndExit(c, c.Command.Name, 1)
}
if c.Args().Get(0) != "local" && c.Args().Get(0) != "remote" {
log.Errorf("Unknown command '%s'\n", c.Args().Get(0))
log.Err(fmt.Errorf("Unknown command '%s'\n", c.Args().Get(0))).Send()
cli.ShowCommandHelpAndExit(c, c.Command.Name, 1)
}
return b.Delete(c.Args().Get(0), c.Args().Get(1), c.Int("command-id"))
Expand Down Expand Up @@ -639,6 +650,6 @@ func main() {
},
}
if err := cliapp.Run(os.Args); err != nil {
log.Fatal(err.Error())
log.Fatal().Err(err).Send()
}
}
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
// wrong INSERT syntax, wait when resolve https://github.com/ClickHouse/clickhouse-go/issues/1345
github.com/ClickHouse/clickhouse-go/v2 v2.23.2
github.com/antchfx/xmlquery v1.4.1
github.com/apex/log v1.9.0
github.com/aws/aws-sdk-go-v2 v1.30.1
github.com/aws/aws-sdk-go-v2/config v1.27.23
github.com/aws/aws-sdk-go-v2/credentials v1.17.23
Expand All @@ -20,7 +19,6 @@ require (
github.com/djherbis/buffer v1.2.0
github.com/djherbis/nio/v3 v3.0.1
github.com/eapache/go-resiliency v1.6.0
github.com/go-logfmt/logfmt v0.6.0
github.com/go-zookeeper/zk v1.0.3
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -49,7 +47,11 @@ require (
gopkg.in/yaml.v3 v3.0.1
)

require golang.org/x/text v0.16.0
require (
github.com/apex/log v1.9.0
github.com/rs/zerolog v1.33.0
golang.org/x/text v0.16.0
)

require (
cloud.google.com/go v0.115.0 // indirect
Expand Down Expand Up @@ -104,7 +106,9 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mozillazg/go-httpheader v0.2.1 // indirect
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
Expand Down
Loading