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

lightning: refine write and ingest logic more like producer-consumer #40692

Merged
merged 41 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cabcb29
--wip-- [skip ci]
lance6716 Jan 17, 2023
2e71066
sync code
lance6716 Jan 17, 2023
4047783
save work
lance6716 Jan 18, 2023
a892b56
Merge branch 'master' into region-job
hawkingrei Jan 18, 2023
086ff97
save work
lance6716 Jan 18, 2023
c7d3e63
revert mis-rename
lance6716 Jan 18, 2023
2310879
revert more
lance6716 Jan 18, 2023
e5ecb07
save work
lance6716 Jan 18, 2023
b7bb3c2
almost finished
lance6716 Jan 19, 2023
0782c3f
fix make bazel
lance6716 Jan 19, 2023
1ce72c8
fix more
lance6716 Jan 19, 2023
d029015
address comments
lance6716 Jan 19, 2023
36bedcb
save work
lance6716 Jan 19, 2023
1621953
fix UT
lance6716 Jan 19, 2023
df937f9
fix UT
lance6716 Jan 19, 2023
e147bbe
fix IT
lance6716 Jan 19, 2023
1aefe14
fix IT
lance6716 Jan 19, 2023
c98157b
try fix CI
lance6716 Jan 20, 2023
f5fe21e
refine more
lance6716 Jan 20, 2023
d04aab6
fix lint
lance6716 Jan 20, 2023
7b2757d
fix CI
lance6716 Jan 20, 2023
d145069
Merge branch 'master' into region-job
lance6716 Jan 28, 2023
fcbdf5e
Merge branch 'master' into region-job
lance6716 Jan 28, 2023
112e5b4
address comment
lance6716 Jan 31, 2023
0f10055
Merge branch 'master' of github.com:pingcap/tidb into region-job
lance6716 Jan 31, 2023
2aa1bd0
address comment
lance6716 Jan 31, 2023
3eea9ec
fix lint
lance6716 Jan 31, 2023
ef3fd83
reset e
lance6716 Feb 23, 2023
63b3999
rename batchWriteKVPairs
lance6716 Feb 23, 2023
cae7f50
rename checkTiKVAvaliable
lance6716 Feb 23, 2023
e12774d
rename needRetryJobs
lance6716 Feb 23, 2023
c1ee4a5
add workGroup.Wait()
lance6716 Feb 23, 2023
5479d51
make j.region.Region a local var
lance6716 Feb 23, 2023
12658e9
add comments to jobStageTp
lance6716 Feb 23, 2023
59ba258
rename checkWriteStall
lance6716 Feb 23, 2023
0370f8d
undo the renaming for function checkWriteStall
lance6716 Feb 23, 2023
103db33
Merge branch 'master' of github.com:pingcap/tidb into region-job
lance6716 Feb 23, 2023
3ab75c2
make bazel_prepare
lance6716 Feb 23, 2023
2c097f3
address comment
lance6716 Feb 23, 2023
5235648
fix a bug that batch is used twice
lance6716 Feb 23, 2023
7ceb901
rename writeAndIngestPairs
lance6716 Feb 27, 2023
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
6 changes: 3 additions & 3 deletions br/pkg/lightning/backend/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
"local_unix_generic.go",
"local_windows.go",
"localhelper.go",
"region_job.go",
],
importpath = "github.com/pingcap/tidb/br/pkg/lightning/backend/local",
visibility = ["//visibility:public"],
Expand All @@ -28,7 +29,6 @@ go_library(
"//br/pkg/lightning/manual",
"//br/pkg/lightning/metric",
"//br/pkg/lightning/tikv",
"//br/pkg/lightning/worker",
"//br/pkg/logutil",
"//br/pkg/membuf",
"//br/pkg/pdutil",
Expand All @@ -40,6 +40,7 @@ go_library(
"//kv",
"//parser/model",
"//parser/mysql",
"//store/pdtypes",
"//table",
"//tablecodec",
"//types",
Expand Down Expand Up @@ -93,19 +94,18 @@ go_test(
"local_check_test.go",
"local_test.go",
"localhelper_test.go",
"region_job_test.go",
],
embed = [":local"],
flaky = True,
shard_count = 45,
deps = [
"//br/pkg/errors",
"//br/pkg/lightning/backend",
"//br/pkg/lightning/backend/kv",
"//br/pkg/lightning/common",
"//br/pkg/lightning/glue",
"//br/pkg/lightning/log",
"//br/pkg/lightning/mydump",
"//br/pkg/lightning/worker",
"//br/pkg/membuf",
"//br/pkg/mock",
"//br/pkg/pdutil",
Expand Down
7 changes: 7 additions & 0 deletions br/pkg/lightning/backend/local/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,14 @@ func (e *Engine) newKVIter(ctx context.Context, opts *pebble.IterOptions) Iter {
return newDupDetectIter(ctx, e.db, e.keyAdapter, opts, e.duplicateDB, logger, e.dupDetectOpt)
}

// getFirstAndLastKey reads the first and last key in range [lowerBound, upperBound)
// in the engine. Empty upperBound means unbounded.
func (e *Engine) getFirstAndLastKey(lowerBound, upperBound []byte) ([]byte, []byte, error) {
if len(upperBound) == 0 {
// we use empty slice for unbounded upper bound, but it means max value in pebble
// so reset to nil
upperBound = nil
}
sleepymole marked this conversation as resolved.
Show resolved Hide resolved
opt := &pebble.IterOptions{
LowerBound: lowerBound,
UpperBound: upperBound,
Expand Down
5 changes: 5 additions & 0 deletions br/pkg/lightning/backend/local/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,9 @@ func TestGetFirstAndLastKey(t *testing.T) {
require.NoError(t, err)
require.Nil(t, first)
require.Nil(t, last)

first, last, err = f.getFirstAndLastKey([]byte("e"), []byte(""))
require.NoError(t, err)
require.Equal(t, []byte("e"), first)
require.Equal(t, []byte("e"), last)
}
Loading