-
Notifications
You must be signed in to change notification settings - Fork 26
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
[to #48] modify TiDB CDC to TiKV CDC #74
Changes from all commits
a330434
d537173
6acd595
8eea41e
2956d83
92a5940
fe8cac1
be501e8
4cf9276
c829e71
62c7f00
6bd0a5c
e0a7e8b
bd77c3a
d8eec09
a61dd5a
f60b0fe
4380a2f
7f5419a
40c9ecb
687fea1
3363a0b
c5da5e5
a878f96
fbdefb7
be8b5dd
78ad01b
d890254
36f9ee8
373086c
fc51e96
7d0ee78
eede5d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,16 +19,13 @@ import ( | |
|
||
"github.com/pingcap/errors" | ||
"github.com/pingcap/log" | ||
tidbkv "github.com/pingcap/tidb/kv" | ||
"github.com/r3labs/diff" | ||
"github.com/tikv/client-go/v2/oracle" | ||
"github.com/tikv/migration/cdc/cdc/entry" | ||
"github.com/tikv/migration/cdc/cdc/kv" | ||
"github.com/tikv/migration/cdc/cdc/model" | ||
"github.com/tikv/migration/cdc/cdc/sink" | ||
"github.com/tikv/migration/cdc/pkg/config" | ||
cerror "github.com/tikv/migration/cdc/pkg/errors" | ||
"github.com/tikv/migration/cdc/pkg/filter" | ||
|
||
"github.com/tikv/migration/cdc/pkg/txnutil/gc" | ||
"github.com/tikv/migration/cdc/pkg/util" | ||
"github.com/tikv/migration/cdc/pkg/version" | ||
|
@@ -80,19 +77,23 @@ func verifyCreateChangefeedConfig(ctx context.Context, changefeedConfig model.Ch | |
|
||
// init replicaConfig | ||
replicaConfig := config.GetDefaultReplicaConfig() | ||
replicaConfig.ForceReplicate = changefeedConfig.ForceReplicate | ||
if changefeedConfig.MounterWorkerNum != 0 { | ||
replicaConfig.Mounter.WorkerNum = changefeedConfig.MounterWorkerNum | ||
} | ||
/* | ||
replicaConfig.ForceReplicate = changefeedConfig.ForceReplicate | ||
if changefeedConfig.MounterWorkerNum != 0 { | ||
replicaConfig.Mounter.WorkerNum = changefeedConfig.MounterWorkerNum | ||
} | ||
*/ | ||
if changefeedConfig.SinkConfig != nil { | ||
replicaConfig.Sink = changefeedConfig.SinkConfig | ||
} | ||
if len(changefeedConfig.IgnoreTxnStartTs) != 0 { | ||
replicaConfig.Filter.IgnoreTxnStartTs = changefeedConfig.IgnoreTxnStartTs | ||
} | ||
if len(changefeedConfig.FilterRules) != 0 { | ||
replicaConfig.Filter.Rules = changefeedConfig.FilterRules | ||
} | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FilterRules are used to filter table. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can modify the filter table to filter keys (or keyspan) to filter keys that users do not need to synchronize. |
||
if len(changefeedConfig.IgnoreTxnStartTs) != 0 { | ||
replicaConfig.Filter.IgnoreTxnStartTs = changefeedConfig.IgnoreTxnStartTs | ||
} | ||
if len(changefeedConfig.FilterRules) != 0 { | ||
replicaConfig.Filter.Rules = changefeedConfig.FilterRules | ||
} | ||
*/ | ||
|
||
captureInfos, err := capture.owner.StatusProvider().GetCaptures(ctx) | ||
if err != nil { | ||
|
@@ -127,16 +128,6 @@ func verifyCreateChangefeedConfig(ctx context.Context, changefeedConfig model.Ch | |
CreatorVersion: version.ReleaseVersion, | ||
} | ||
|
||
if !replicaConfig.ForceReplicate && !changefeedConfig.IgnoreIneligibleTable { | ||
ineligibleTables, _, err := verifyTables(replicaConfig, capture.kvStorage, changefeedConfig.StartTS) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(ineligibleTables) != 0 { | ||
return nil, cerror.ErrTableIneligible.GenWithStackByArgs(ineligibleTables) | ||
} | ||
} | ||
|
||
tz, err := util.GetTimezone(changefeedConfig.TimeZone) | ||
if err != nil { | ||
return nil, cerror.ErrAPIInvalidParam.Wrap(errors.Annotatef(err, "invalid timezone:%s", changefeedConfig.TimeZone)) | ||
|
@@ -164,22 +155,6 @@ func verifyUpdateChangefeedConfig(ctx context.Context, changefeedConfig model.Ch | |
} | ||
|
||
// verify rules | ||
if len(changefeedConfig.FilterRules) != 0 { | ||
newInfo.Config.Filter.Rules = changefeedConfig.FilterRules | ||
_, err = filter.VerifyRules(newInfo.Config) | ||
if err != nil { | ||
return nil, cerror.ErrChangefeedUpdateRefused.GenWithStackByArgs(err.Error()) | ||
} | ||
} | ||
|
||
if len(changefeedConfig.IgnoreTxnStartTs) != 0 { | ||
newInfo.Config.Filter.IgnoreTxnStartTs = changefeedConfig.IgnoreTxnStartTs | ||
} | ||
|
||
if changefeedConfig.MounterWorkerNum != 0 { | ||
newInfo.Config.Mounter.WorkerNum = changefeedConfig.MounterWorkerNum | ||
} | ||
|
||
if changefeedConfig.SinkConfig != nil { | ||
newInfo.Config.Sink = changefeedConfig.SinkConfig | ||
} | ||
|
@@ -198,30 +173,3 @@ func verifyUpdateChangefeedConfig(ctx context.Context, changefeedConfig model.Ch | |
|
||
return newInfo, nil | ||
} | ||
|
||
func verifyTables(replicaConfig *config.ReplicaConfig, storage tidbkv.Storage, startTs uint64) (ineligibleTables, eligibleTables []model.TableName, err error) { | ||
filter, err := filter.NewFilter(replicaConfig) | ||
if err != nil { | ||
return nil, nil, errors.Trace(err) | ||
} | ||
meta, err := kv.GetSnapshotMeta(storage, startTs) | ||
if err != nil { | ||
return nil, nil, errors.Trace(err) | ||
} | ||
snap, err := entry.NewSingleSchemaSnapshotFromMeta(meta, startTs, false /* explicitTables */) | ||
if err != nil { | ||
return nil, nil, errors.Trace(err) | ||
} | ||
|
||
for _, tableInfo := range snap.Tables() { | ||
if filter.ShouldIgnoreTable(tableInfo.TableName.Schema, tableInfo.TableName.Table) { | ||
continue | ||
} | ||
if !tableInfo.IsEligible(false /* forceReplicate */) { | ||
ineligibleTables = append(ineligibleTables, tableInfo.TableName) | ||
} else { | ||
eligibleTables = append(eligibleTables, tableInfo.TableName) | ||
} | ||
} | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sorter module is used to sort transactions by commit ts to ensure that the transactions entered by cdc are in the same order as commit ts. Now rawkv don't it (We also need to add sorter for txnkv later).