forked from pingcap/br
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multi-engine per table (batching) (pingcap#113)
* config,restore: introduced `[mydumper] batch-size` Removed `[tikv-importer] batch-size` to avoid confusion. Removed `[mydumper] min-region-size` since it is useless now. * restore,mydump: pre-allocate engine IDs * restore: separate table checkpoints and engine checkpoints * importer: stop exposing the UUID * checkpoints: make checkpoint diff understand 1 table = many engines * checkpoints: make file checkpoints recognize multiple engines * checkpoints: migrated MySQL-based checkpoint to multi-engine as well * restore: adapt restore workflow for multi-engine * tests: added test case for multi-engine * *: fixed code * *: addressed comments * *: addressed comments * Support non-uniform batch size (pingcap#114) * mydump: non-uniform batch size * *: make the `batch-size-scale` configurable * *: implemented the optimized non-uniform strategy * tests: due to change of strategy, checkpoint_engines count becomes 4 again * mydump/region: slightly adjust the batch size computation * Use the exact result of 1/Beta(N, R) instead of an approximation * When the number of engines is small and the total engine size of the first (table-concurrency) batches exceed the table size, the last batch was truncated, and disrupt the pipeline. Now in these case we will reduce the batch size to avoid this disruption. * restore: log the SQL size and KV size of each engine for debugging * config: change default batch size and ratio given experiment result * config: added more explanation about batch-import-ratio Co-authored-by: Lonng <chris@lonng.org>
- Loading branch information
Showing
27 changed files
with
1,269 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package common | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
// OnceError is an error value which will can be assigned once. | ||
// | ||
// The zero value is ready for use. | ||
type OnceError struct { | ||
lock sync.Mutex | ||
err error | ||
} | ||
|
||
// Set assigns an error to this instance, if `e != nil`. | ||
// | ||
// If this method is called multiple times, only the first call is effective. | ||
func (oe *OnceError) Set(tag string, e error) { | ||
if e != nil { | ||
oe.lock.Lock() | ||
if oe.err == nil { | ||
oe.err = e | ||
} | ||
oe.lock.Unlock() | ||
if !IsContextCanceledError(e) { | ||
AppLogger.Errorf("[%s] error %v", tag, e) | ||
} | ||
} | ||
} | ||
|
||
// Get returns the first error value stored in this instance. | ||
func (oe *OnceError) Get() error { | ||
oe.lock.Lock() | ||
defer oe.lock.Unlock() | ||
return oe.err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package common_test | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
. "github.com/pingcap/check" | ||
"github.com/pingcap/tidb-lightning/lightning/common" | ||
) | ||
|
||
func TestCommon(t *testing.T) { | ||
TestingT(t) | ||
} | ||
|
||
var _ = Suite(&onceErrorSuite{}) | ||
|
||
type onceErrorSuite struct{} | ||
|
||
func (s *onceErrorSuite) TestOnceError(c *C) { | ||
var err common.OnceError | ||
|
||
c.Assert(err.Get(), IsNil) | ||
|
||
err.Set("tag", nil) | ||
c.Assert(err.Get(), IsNil) | ||
|
||
e := errors.New("1") | ||
err.Set("tag", e) | ||
c.Assert(err.Get(), Equals, e) | ||
|
||
e2 := errors.New("2") | ||
err.Set("tag", e2) | ||
c.Assert(err.Get(), Equals, e) // e, not e2. | ||
|
||
err.Set("tag", nil) | ||
c.Assert(err.Get(), Equals, e) | ||
|
||
ch := make(chan struct{}) | ||
go func() { | ||
err.Set("tag", nil) | ||
ch <- struct{}{} | ||
}() | ||
<-ch | ||
c.Assert(err.Get(), Equals, e) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,4 @@ const ( | |
MinRegionSize int64 = 256 * _M | ||
|
||
BufferSizeScale = 5 | ||
|
||
// kv import | ||
KVMaxBatchSize int64 = 200 * _G | ||
) |
Oops, something went wrong.