Skip to content

Commit

Permalink
deal comments
Browse files Browse the repository at this point in the history
Signed-off-by: joccau <[email protected]>
  • Loading branch information
joccau committed Sep 6, 2024
1 parent 7d148d2 commit 2912251
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/domain/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestTetchAllSchemasWithTablesWithFailpoint(t *testing.T) {
require.Equal(t, len(dbs), 1003)

// inject the failpoint
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/domain/failed-fetch-schemas-with-tables", "1*return(true)"))
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/domain/failed-fetch-schemas-with-tables", "1*return()"))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/domain/failed-fetch-schemas-with-tables"))
}()
Expand Down
11 changes: 5 additions & 6 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ import (
"go.etcd.io/etcd/client/v3/concurrency"
atomicutil "go.uber.org/atomic"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/keepalive"
Expand Down Expand Up @@ -448,13 +447,13 @@ func (do *Domain) fetchAllSchemasWithTables(m *meta.Meta) ([]*model.DBInfo, erro
}

splittedSchemas := do.splitForConcurrentFetch(allSchemas)

eg, ectx := errgroup.WithContext(context.Background())
concurrency := min(len(splittedSchemas), 128)
workers := util.NewWorkerPool(uint(concurrency), "fetch schemas with tables")

eg, ectx := util.NewErrorGroupWithRecoverWithCtx(context.Background())
eg.SetLimit(concurrency)
for _, schemas := range splittedSchemas {
ss := schemas
workers.ApplyOnErrorGroup(eg, func() error {
eg.Go(func() error {
return do.fetchSchemasWithTables(ectx, ss, m)
})
}
Expand Down Expand Up @@ -490,7 +489,7 @@ func (*Domain) splitForConcurrentFetch(schemas []*model.DBInfo) [][]*model.DBInf
}

func (*Domain) fetchSchemasWithTables(ctx context.Context, schemas []*model.DBInfo, m *meta.Meta) error {
failpoint.Inject("failed-fetch-schemas-with-tables", func(_ failpoint.Value) {
failpoint.Inject("failed-fetch-schemas-with-tables", func() {
failpoint.Return(errors.New("failpoint: failed to fetch schemas with tables"))
})

Expand Down

0 comments on commit 2912251

Please sign in to comment.