Skip to content

Commit aec0fc5

Browse files
authored
lightning: calculate concurrency of schema import from region-concurrency (#58202)
close #58141
1 parent c8ba4e3 commit aec0fc5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightning/pkg/importer/import.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@ func (rc *Controller) restoreSchema(ctx context.Context) error {
593593
// we can handle the duplicated created with createIfNotExist statement
594594
// and we will check the schema in TiDB is valid with the datafile in DataCheck later.
595595
logger := log.FromContext(ctx)
596-
concurrency := min(rc.cfg.App.RegionConcurrency, 8)
596+
// the minimum 4 comes the fact that when connect to non-owner TiDB, the max
597+
// QPS is 2 per connection due to polling every 500ms.
598+
concurrency := max(2*rc.cfg.App.RegionConcurrency, 4)
597599
// sql.DB is a connection pool, we set it to concurrency + 1(for job generator)
598600
// to reuse connections, as we might call db.Conn/conn.Close many times.
599601
// there's no API to get sql.DB.MaxIdleConns, so we revert to its default which is 2

0 commit comments

Comments
 (0)