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

[fix #193] fix cdc lose data by add resolved ts interval #196

Merged
merged 16 commits into from
Aug 8, 2022

Conversation

zeminzhou
Copy link
Contributor

Signed-off-by: zeminzhou [email protected]

What problem does this PR solve?

TiKV-CDC maybe lose data when region leader tranfer happend

Issue Number: close #193

Problem Description: TBD

What is changed and how does it work?

Add a safe interval for resolved ts

Code changes

  • Has exported function/method change

Check List for Tests

This PR has been tested by at least one of the following methods:

  • Unit test
  • Manual test (add detailed scripts or steps below)

Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
@zeminzhou zeminzhou requested review from haojinming and pingyu August 6, 2022 10:06
Signed-off-by: zeminzhou <[email protected]>
cdc/pkg/config/kvclient.go Outdated Show resolved Hide resolved
cdc/cdc/kv/region_worker.go Outdated Show resolved Hide resolved
logicalTs := oracle.ExtractLogical(resolvedTs)
time := oracle.GetTimeFromTS(resolvedTs)

safeTime := time.Add(-cfg.ResolvedTsSafeInterval)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If time is less than cfg.ResolvedTsSafeInterval, suggest to just return the time.
A resolved-ts = 0 would be a legal one ?

cdc/cdc/kv/region_worker.go Show resolved Hide resolved
cdc/cdc/kv/region_worker.go Outdated Show resolved Hide resolved
cdc/cdc/kv/region_worker.go Outdated Show resolved Hide resolved
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Copy link
Contributor

@haojinming haojinming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~

Signed-off-by: zeminzhou <[email protected]>
Comment on lines 735 to 736
// resolved ts, which may be larger than the new leader appends key to ts.
// So we fallback the resolved ts to a safe interval to make sure it's correct.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// resolved ts, which may be larger than the new leader appends key to ts.
// So we fallback the resolved ts to a safe interval to make sure it's correct.
// So we fallback the resolved ts to a safe interval to make sure it's correct.
// See https://github.com/tikv/migration/issues/193.
// TODO: fix the issue completely.

Also suggest to write a full analysis in #193, to help us discuss with others, and completely fix it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

cdc/cdc/kv/region_worker.go Outdated Show resolved Hide resolved
resolvedTs: (1<<18)*4*1000 + 1,
expected: (1<<18)*1000 + 1,
},
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to add boundary cases, e.g:

  1. resolvedTs = 0
  2. Physical clock less than 3s.
  3. Physical clock equals to 3s.

cdc/pkg/config/kvclient.go Outdated Show resolved Hide resolved
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
@zeminzhou
Copy link
Contributor Author

@pingyu PTAL~

Copy link
Collaborator

@pingyu pingyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~

@pingyu pingyu merged commit 67011f4 into tikv:main Aug 8, 2022
@zeminzhou zeminzhou deleted the resolved-ts-x1 branch August 23, 2022 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cdc: Data may be lost during leader transfer
3 participants