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 17 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 @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
golang-version:
- "1.20"
- "1.21"
steps:
- name: Checkout project
uses: actions/checkout@v3
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
strategy:
matrix:
golang-version:
- "1.20"
- "1.21"
clickhouse:
- '1.1.54394'
- '19.17'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
golang-version:
- "1.20"
- "1.21"

steps:
- name: Checkout project
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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 not exists during create, affected 2.2.7 version, look details [676](https://github.com/Altinity/clickhouse-backup/issues/676#issue-1771732489)
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ RUN rm -fv /etc/apt/sources.list.d/clickhouse.list && \
echo "deb https://ppa.launchpadcontent.net/longsleep/golang-backports/ubuntu ${DISTRIB_CODENAME} main" > /etc/apt/sources.list.d/golang.list && \
echo "deb-src https://ppa.launchpadcontent.net/longsleep/golang-backports/ubuntu ${DISTRIB_CODENAME} main" >> /etc/apt/sources.list.d/golang.list && \
( apt-get update || true ) && \
apt-get install -y --no-install-recommends libc-dev golang-1.20 make git gcc musl-dev musl-tools && \
apt-get install -y --no-install-recommends libc-dev golang-1.21 make git gcc musl-dev musl-tools && \
wget -q -P /root/ https://musl.cc/aarch64-linux-musl-cross.tgz && \
tar -xvf /root/aarch64-linux-musl-cross.tgz -C /root/ && \
mkdir -p /root/go/

RUN ln -nsfv /usr/lib/go-1.20/bin/go /usr/bin/go
RUN ln -nsfv /usr/lib/go-1.21/bin/go /usr/bin/go
VOLUME /root/.cache/go
ENV GOCACHE=/root/.cache/go
ENV GOPATH=/root/go/
ENV GOROOT=/usr/lib/go-1.20/
ENV GOROOT=/usr/lib/go-1.21/
RUN go env
WORKDIR /src/
# cache modules when go.mod go.sum changed
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Vagrant.configure(2) do |config|
apt-get install --no-install-recommends -y clickhouse-client clickhouse-server

# golang
export GOLANG_VERSION=1.20
export GOLANG_VERSION=1.21
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 52B59B1571A79DBC054901C0F6BC817356A3D45E
add-apt-repository ppa:longsleep/golang-backports
apt-get install --no-install-recommends -y golang-${GOLANG_VERSION}
Expand Down
28 changes: 19 additions & 9 deletions cmd/clickhouse-backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package main
import (
"context"
"fmt"
stdlog "log"
"os"
"strings"

"github.com/Altinity/clickhouse-backup/pkg/config"
"github.com/Altinity/clickhouse-backup/pkg/logcli"
"github.com/Altinity/clickhouse-backup/pkg/status"

"github.com/Altinity/clickhouse-backup/pkg/backup"
"github.com/Altinity/clickhouse-backup/pkg/config"
"github.com/Altinity/clickhouse-backup/pkg/server"
"github.com/Altinity/clickhouse-backup/pkg/status"

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

Expand All @@ -24,7 +25,16 @@ var (
)

func main() {
log.SetHandler(logcli.New(os.Stdout))
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout, 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 @@ -458,11 +468,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 @@ -597,6 +607,6 @@ func main() {
},
}
if err := cliapp.Run(os.Args); err != nil {
log.Fatal(err.Error())
log.Fatal().Err(err).Send()
}
}
108 changes: 55 additions & 53 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
module github.com/Altinity/clickhouse-backup

require (
cloud.google.com/go/storage v1.30.1
cloud.google.com/go/storage v1.31.0
github.com/Azure/azure-pipeline-go v0.2.3
github.com/Azure/azure-storage-blob-go v0.15.0
github.com/Azure/go-autorest/autorest v0.11.29
github.com/Azure/go-autorest/autorest/adal v0.9.23
github.com/ClickHouse/clickhouse-go/v2 v2.10.1
github.com/antchfx/xmlquery v1.3.16
github.com/ClickHouse/clickhouse-go/v2 v2.13.0
github.com/antchfx/xmlquery v1.3.17
github.com/apex/log v1.9.0
github.com/aws/aws-sdk-go-v2 v1.18.1
github.com/aws/aws-sdk-go-v2/config v1.18.26
github.com/aws/aws-sdk-go-v2/credentials v1.13.25
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.68
github.com/aws/aws-sdk-go-v2/service/s3 v1.34.0
github.com/aws/aws-sdk-go-v2/service/sts v1.19.1
github.com/aws/smithy-go v1.13.5
github.com/aws/aws-sdk-go-v2 v1.20.1
github.com/aws/aws-sdk-go-v2/config v1.18.33
github.com/aws/aws-sdk-go-v2/credentials v1.13.32
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.77
github.com/aws/aws-sdk-go-v2/service/s3 v1.38.2
github.com/aws/aws-sdk-go-v2/service/sts v1.21.2
github.com/aws/smithy-go v1.14.1
github.com/djherbis/buffer v1.2.0
github.com/djherbis/nio/v3 v3.0.1
github.com/eapache/go-resiliency v1.3.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.3.0
github.com/gorilla/mux v1.8.0
github.com/jlaffaye/ftp v0.2.0
github.com/jolestar/go-commons-pool/v2 v2.1.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/klauspost/compress v1.16.6
github.com/klauspost/compress v1.16.7
github.com/mattn/go-shellwords v1.0.12
github.com/mholt/archiver/v4 v4.0.0-alpha.8
github.com/otiai10/copy v1.11.0
github.com/otiai10/copy v1.12.0
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.13.5
github.com/prometheus/client_golang v1.15.1
github.com/pkg/sftp v1.13.6
github.com/prometheus/client_golang v1.16.0
github.com/rs/zerolog v1.30.0
github.com/stretchr/testify v1.8.4
github.com/tencentyun/cos-go-sdk-v5 v0.7.41
github.com/tencentyun/cos-go-sdk-v5 v0.7.42
github.com/urfave/cli v1.22.14
github.com/yargevad/filepathx v1.0.0
golang.org/x/crypto v0.10.0
golang.org/x/mod v0.8.0
golang.org/x/crypto v0.12.0
golang.org/x/mod v0.12.0
golang.org/x/sync v0.3.0
google.golang.org/api v0.127.0
google.golang.org/api v0.136.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
gopkg.in/yaml.v3 v3.0.1
)

require (
cloud.google.com/go v0.110.2 // indirect
cloud.google.com/go/compute v1.20.0 // indirect
cloud.google.com/go v0.110.7 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.0 // indirect
cloud.google.com/go/iam v1.1.2 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/ClickHouse/ch-go v0.56.1 // indirect
github.com/ClickHouse/ch-go v0.58.0 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/antchfx/xpath v1.2.4 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.26 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.29 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.11 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.11 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.12 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.13 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.33 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.13.2 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bodgit/plumbing v1.3.0 // indirect
github.com/bodgit/sevenzip v1.4.2 // indirect
github.com/bodgit/sevenzip v1.4.3 // indirect
github.com/bodgit/windows v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/clbanning/mxj v1.8.4 // indirect
Expand All @@ -87,26 +87,28 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
github.com/google/s2a-go v0.1.5 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/pgzip v1.2.6 // 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.11 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mozillazg/go-httpheader v0.3.1 // indirect
github.com/mozillazg/go-httpheader v0.4.0 // indirect
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
github.com/paulmach/orb v0.9.2 // indirect
github.com/paulmach/orb v0.10.0 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
Expand All @@ -117,17 +119,17 @@ require (
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/genproto v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

go 1.20
go 1.21
Loading