Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

poor: resume task if sync unit exits with invalid connection error #66

Merged
merged 5 commits into from
Mar 7, 2019
Merged

poor: resume task if sync unit exits with invalid connection error #66

merged 5 commits into from
Mar 7, 2019

Conversation

IANTHEREAL
Copy link
Collaborator

What problem does this PR solve?

try to resume task if sync unit exits with invalid connection error

What is changed and how it works?

it's a poor and very rough retry feature, the main reason is that the concurrency control of the sub task module is very confusing and needs to be optimized. After improve its state transition and concurrency control, I will optimize the implementation of retry feature.

Check List

Tests

  • Manual test (add detailed scripts or steps below)
    • set up a dm cluster
    • start a task
    • interfere network to let connetion timeout
    • check whether dm-worker would try to resume task

@IANTHEREAL IANTHEREAL added status/PTAL This PR is ready for review. Add this label back after committing new changes type/enhancement Performance improvement or refactoring labels Mar 5, 2019
if len(result.Errors) == 0 {
if result.IsCanceled {
stage = pb.Stage_Stopped // canceled by user
} else {
stage = pb.Stage_Finished // process finished with no error
}
} else {
/* TODO
it's a poor and very rough retry feature, the main reason is that
the concurrency control of the sub task module is very confusing and needs to be optimized.
Copy link
Contributor

@amyangfei amyangfei Mar 6, 2019

Choose a reason for hiding this comment

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

Is the concurrency control optimization including the following scenario?
all of DM-worker's connections to downstream TiDB suddenly reset by downstream(caused by TiDB restart, network cutting etc.), then we must recover each connection in syncer and if the worker-count config of syncer is N, we will wait (N + 1) * 10 seconds at most.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

first of all it is concurrent, I don't understand why we need to wait (N + 1) * 10 seconds at most.
For the refactoring, more is the reconstruction of the the structure, making the moudle and funcion more reasone, of course we can increase the backoff property

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean for each subtask, (N + 1) * 10 seconds may be not continuous, but each DB connection must be recovered. So the worst case is (N + 1) * 10 seconds sums up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but it's real concurrent, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's the logic of unit, we can refine while refactoring sync unit

Copy link
Member

Choose a reason for hiding this comment

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

we can refactor units one by one and then the outer state transition later.

dm/worker/subtask.go Outdated Show resolved Hide resolved
switch current.Type() {
case pb.UnitType_Sync:
for _, err := range errors {
if strings.Contains(err.Msg, "invalid connection") {
Copy link
Member

@csuzhangxc csuzhangxc Mar 7, 2019

Choose a reason for hiding this comment

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

should we need to close all DB connections and re-open them in sync unit?
some users reported that they need to resume-task multi times when "invalid connection" occurred.

@csuzhangxc
Copy link
Member

LGTM

@csuzhangxc csuzhangxc added status/LGT1 One reviewer already commented LGTM and removed status/PTAL This PR is ready for review. Add this label back after committing new changes labels Mar 7, 2019
@amyangfei amyangfei added status/LGT2 Two reviewers already commented LGTM, ready for merge and removed status/LGT1 One reviewer already commented LGTM labels Mar 7, 2019
@IANTHEREAL IANTHEREAL merged commit 1120003 into pingcap:master Mar 7, 2019
@IANTHEREAL IANTHEREAL deleted the ian/retry branch March 7, 2019 10:02
lichunzhu pushed a commit to lichunzhu/dm that referenced this pull request Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/LGT2 Two reviewers already commented LGTM, ready for merge type/enhancement Performance improvement or refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants