From 909a08febe7c8e7c4eaf582f8d7b4f39a8fa9f69 Mon Sep 17 00:00:00 2001 From: dongmen <414110582@qq.com> Date: Thu, 20 Apr 2023 10:52:23 +0800 Subject: [PATCH 1/8] add AutoSyncInterval when new etcd client --- cdc/api/v2/api_helpers.go | 9 +++++---- cdc/server/server.go | 9 +++++---- dm/pkg/etcdutil/etcdutil.go | 7 ++++--- pkg/cmd/factory/factory_impl.go | 11 ++++++----- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cdc/api/v2/api_helpers.go b/cdc/api/v2/api_helpers.go index 25354804aaf..f3c039b8855 100644 --- a/cdc/api/v2/api_helpers.go +++ b/cdc/api/v2/api_helpers.go @@ -483,10 +483,11 @@ func (h APIV2HelpersImpl) getEtcdClient( logConfig.Level = zap.NewAtomicLevelAt(zapcore.ErrorLevel) return clientv3.New( clientv3.Config{ - Endpoints: pdAddrs, - TLS: tlsCfg, - LogConfig: logConfig, - DialTimeout: 5 * time.Second, + Endpoints: pdAddrs, + TLS: tlsCfg, + LogConfig: logConfig, + DialTimeout: 5 * time.Second, + AutoSyncInterval: 3 * time.Second, DialOptions: []grpc.DialOption{ grpcTLSOption, grpc.WithBlock(), diff --git a/cdc/server/server.go b/cdc/server/server.go index ecc60b30dd7..a2556b6dcc0 100644 --- a/cdc/server/server.go +++ b/cdc/server/server.go @@ -146,10 +146,11 @@ func (s *server) prepare(ctx context.Context) error { // then cause the new owner cannot be elected immediately after the old owner offline. // see https://github.com/etcd-io/etcd/blob/525d53bd41/client/v3/concurrency/election.go#L98 etcdCli, err := clientv3.New(clientv3.Config{ - Endpoints: s.pdEndpoints, - TLS: tlsConfig, - LogConfig: &logConfig, - DialTimeout: 5 * time.Second, + Endpoints: s.pdEndpoints, + TLS: tlsConfig, + LogConfig: &logConfig, + DialTimeout: 5 * time.Second, + AutoSyncInterval: 3 * time.Second, DialOptions: []grpc.DialOption{ grpcTLSOption, grpc.WithBlock(), diff --git a/dm/pkg/etcdutil/etcdutil.go b/dm/pkg/etcdutil/etcdutil.go index a8cbec291e6..5b60718ac55 100644 --- a/dm/pkg/etcdutil/etcdutil.go +++ b/dm/pkg/etcdutil/etcdutil.go @@ -60,9 +60,10 @@ var etcdDefaultTxnStrategy = retry.FiniteRetryStrategy{} // CreateClient creates an etcd client with some default config items. func CreateClient(endpoints []string, tlsCfg *tls.Config) (*clientv3.Client, error) { return clientv3.New(clientv3.Config{ - Endpoints: endpoints, - DialTimeout: DefaultDialTimeout, - TLS: tlsCfg, + Endpoints: endpoints, + DialTimeout: DefaultDialTimeout, + AutoSyncInterval: 3 * time.Second, + TLS: tlsCfg, }) } diff --git a/pkg/cmd/factory/factory_impl.go b/pkg/cmd/factory/factory_impl.go index 8c73335110f..2c86828f591 100644 --- a/pkg/cmd/factory/factory_impl.go +++ b/pkg/cmd/factory/factory_impl.go @@ -110,11 +110,12 @@ func (f *factoryImpl) EtcdClient() (*etcd.CDCEtcdClientImpl, error) { pdEndpoints := strings.Split(pdAddr, ",") etcdClient, err := clientv3.New(clientv3.Config{ - Context: ctx, - Endpoints: pdEndpoints, - TLS: tlsConfig, - LogConfig: &logConfig, - DialTimeout: 30 * time.Second, + Context: ctx, + Endpoints: pdEndpoints, + TLS: tlsConfig, + LogConfig: &logConfig, + DialTimeout: 30 * time.Second, + AutoSyncInterval: 3 * time.Second, // TODO(hi-rustin): add gRPC metrics to Options. // See also: https://github.com/pingcap/tiflow/pull/2341#discussion_r673018537. DialOptions: []grpc.DialOption{ From c3fb6b369798af55c492afc8477ca264e94c2799 Mon Sep 17 00:00:00 2001 From: dongmen <414110582@qq.com> Date: Thu, 27 Apr 2023 18:56:45 +0800 Subject: [PATCH 2/8] remove cli change --- cdc/api/v2/api_helpers.go | 9 ++++----- pkg/cmd/factory/factory_impl.go | 11 +++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cdc/api/v2/api_helpers.go b/cdc/api/v2/api_helpers.go index f3c039b8855..25354804aaf 100644 --- a/cdc/api/v2/api_helpers.go +++ b/cdc/api/v2/api_helpers.go @@ -483,11 +483,10 @@ func (h APIV2HelpersImpl) getEtcdClient( logConfig.Level = zap.NewAtomicLevelAt(zapcore.ErrorLevel) return clientv3.New( clientv3.Config{ - Endpoints: pdAddrs, - TLS: tlsCfg, - LogConfig: logConfig, - DialTimeout: 5 * time.Second, - AutoSyncInterval: 3 * time.Second, + Endpoints: pdAddrs, + TLS: tlsCfg, + LogConfig: logConfig, + DialTimeout: 5 * time.Second, DialOptions: []grpc.DialOption{ grpcTLSOption, grpc.WithBlock(), diff --git a/pkg/cmd/factory/factory_impl.go b/pkg/cmd/factory/factory_impl.go index 2c86828f591..8c73335110f 100644 --- a/pkg/cmd/factory/factory_impl.go +++ b/pkg/cmd/factory/factory_impl.go @@ -110,12 +110,11 @@ func (f *factoryImpl) EtcdClient() (*etcd.CDCEtcdClientImpl, error) { pdEndpoints := strings.Split(pdAddr, ",") etcdClient, err := clientv3.New(clientv3.Config{ - Context: ctx, - Endpoints: pdEndpoints, - TLS: tlsConfig, - LogConfig: &logConfig, - DialTimeout: 30 * time.Second, - AutoSyncInterval: 3 * time.Second, + Context: ctx, + Endpoints: pdEndpoints, + TLS: tlsConfig, + LogConfig: &logConfig, + DialTimeout: 30 * time.Second, // TODO(hi-rustin): add gRPC metrics to Options. // See also: https://github.com/pingcap/tiflow/pull/2341#discussion_r673018537. DialOptions: []grpc.DialOption{ From 8974284af6ec162640795ed9dff0dec5f5f16804 Mon Sep 17 00:00:00 2001 From: dongmen <414110582@qq.com> Date: Thu, 27 Apr 2023 19:38:41 +0800 Subject: [PATCH 3/8] fix it --- cdc/server/server.go | 2 +- dm/pkg/etcdutil/etcdutil.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cdc/server/server.go b/cdc/server/server.go index dacef85693e..b9dbdbe6ec5 100644 --- a/cdc/server/server.go +++ b/cdc/server/server.go @@ -151,7 +151,7 @@ func (s *server) prepare(ctx context.Context) error { TLS: tlsConfig, LogConfig: &logConfig, DialTimeout: 5 * time.Second, - AutoSyncInterval: 3 * time.Second, + AutoSyncInterval: 30 * time.Second, DialOptions: []grpc.DialOption{ grpcTLSOption, grpc.WithBlock(), diff --git a/dm/pkg/etcdutil/etcdutil.go b/dm/pkg/etcdutil/etcdutil.go index 5b60718ac55..d0ba3df8faa 100644 --- a/dm/pkg/etcdutil/etcdutil.go +++ b/dm/pkg/etcdutil/etcdutil.go @@ -62,7 +62,7 @@ func CreateClient(endpoints []string, tlsCfg *tls.Config) (*clientv3.Client, err return clientv3.New(clientv3.Config{ Endpoints: endpoints, DialTimeout: DefaultDialTimeout, - AutoSyncInterval: 3 * time.Second, + AutoSyncInterval: 30 * time.Second, TLS: tlsCfg, }) } From 33a77fa5afe202d1e1fa4b3222cd4099e25d2a27 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Fri, 28 Apr 2023 18:01:51 +0800 Subject: [PATCH 4/8] pkg/sink(ticdc): test --- tests/integration_tests/http_proxies/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests/http_proxies/run.sh b/tests/integration_tests/http_proxies/run.sh index 74239cf6161..51e32e0f1f7 100644 --- a/tests/integration_tests/http_proxies/run.sh +++ b/tests/integration_tests/http_proxies/run.sh @@ -50,7 +50,7 @@ function prepare() { start_proxy # TODO: make sure the proxy is started. - sleep 5 + sleep 50 export http_proxy=http://127.0.0.1:$proxy_port export https_proxy=http://127.0.0.1:$proxy_port ensure 10 curl http://$UP_PD_HOST_1:2379/ From 35fbd5f76dbbc45bb5df0c6383a17d2241647646 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Fri, 28 Apr 2023 18:02:38 +0800 Subject: [PATCH 5/8] pkg/sink(ticdc): test --- cdc/server/server.go | 2 +- dm/pkg/etcdutil/etcdutil.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cdc/server/server.go b/cdc/server/server.go index b9dbdbe6ec5..dacef85693e 100644 --- a/cdc/server/server.go +++ b/cdc/server/server.go @@ -151,7 +151,7 @@ func (s *server) prepare(ctx context.Context) error { TLS: tlsConfig, LogConfig: &logConfig, DialTimeout: 5 * time.Second, - AutoSyncInterval: 30 * time.Second, + AutoSyncInterval: 3 * time.Second, DialOptions: []grpc.DialOption{ grpcTLSOption, grpc.WithBlock(), diff --git a/dm/pkg/etcdutil/etcdutil.go b/dm/pkg/etcdutil/etcdutil.go index d0ba3df8faa..5b60718ac55 100644 --- a/dm/pkg/etcdutil/etcdutil.go +++ b/dm/pkg/etcdutil/etcdutil.go @@ -62,7 +62,7 @@ func CreateClient(endpoints []string, tlsCfg *tls.Config) (*clientv3.Client, err return clientv3.New(clientv3.Config{ Endpoints: endpoints, DialTimeout: DefaultDialTimeout, - AutoSyncInterval: 30 * time.Second, + AutoSyncInterval: 3 * time.Second, TLS: tlsCfg, }) } From c8cb7b0656beb28e1d9bc17fe4fe791483bc1681 Mon Sep 17 00:00:00 2001 From: dongmen <414110582@qq.com> Date: Sat, 6 May 2023 17:34:24 +0800 Subject: [PATCH 6/8] fix error --- cdc/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdc/server/server.go b/cdc/server/server.go index dacef85693e..b9dbdbe6ec5 100644 --- a/cdc/server/server.go +++ b/cdc/server/server.go @@ -151,7 +151,7 @@ func (s *server) prepare(ctx context.Context) error { TLS: tlsConfig, LogConfig: &logConfig, DialTimeout: 5 * time.Second, - AutoSyncInterval: 3 * time.Second, + AutoSyncInterval: 30 * time.Second, DialOptions: []grpc.DialOption{ grpcTLSOption, grpc.WithBlock(), From 4b29653d622da6abf49e9ac48b54a12d3adacc42 Mon Sep 17 00:00:00 2001 From: dongmen <414110582@qq.com> Date: Sat, 6 May 2023 17:35:46 +0800 Subject: [PATCH 7/8] fix error 2 --- dm/pkg/etcdutil/etcdutil.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/pkg/etcdutil/etcdutil.go b/dm/pkg/etcdutil/etcdutil.go index 5b60718ac55..d0ba3df8faa 100644 --- a/dm/pkg/etcdutil/etcdutil.go +++ b/dm/pkg/etcdutil/etcdutil.go @@ -62,7 +62,7 @@ func CreateClient(endpoints []string, tlsCfg *tls.Config) (*clientv3.Client, err return clientv3.New(clientv3.Config{ Endpoints: endpoints, DialTimeout: DefaultDialTimeout, - AutoSyncInterval: 3 * time.Second, + AutoSyncInterval: 30 * time.Second, TLS: tlsCfg, }) } From 57d24fe2fc868f9dd59d6cb214ec72201f2edec4 Mon Sep 17 00:00:00 2001 From: dongmen <414110582@qq.com> Date: Sat, 6 May 2023 17:37:03 +0800 Subject: [PATCH 8/8] revert useless change --- tests/integration_tests/http_proxies/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests/http_proxies/run.sh b/tests/integration_tests/http_proxies/run.sh index 51e32e0f1f7..74239cf6161 100644 --- a/tests/integration_tests/http_proxies/run.sh +++ b/tests/integration_tests/http_proxies/run.sh @@ -50,7 +50,7 @@ function prepare() { start_proxy # TODO: make sure the proxy is started. - sleep 50 + sleep 5 export http_proxy=http://127.0.0.1:$proxy_port export https_proxy=http://127.0.0.1:$proxy_port ensure 10 curl http://$UP_PD_HOST_1:2379/