-
Notifications
You must be signed in to change notification settings - Fork 131
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
pkg/loader: fix loader run while quitting #749
Conversation
/run-all-tests |
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.
When loader.Run
stopped, MySQLSyncer
would call setErr
, and the errCh
channel would be closed regardless of whether the passed error is nil
or not.
So maybe we can simply wrap the blocking loader.Input() <-
with a select like the following to solve the problem.
diff --git a/drainer/sync/mysql.go b/drainer/sync/mysql.go
index c9067b3e..10343e3e 100644
--- a/drainer/sync/mysql.go
+++ b/drainer/sync/mysql.go
@@ -83,9 +83,12 @@ func (m *MysqlSyncer) Sync(item *Item) error {
txn.Metadata = item
- m.loader.Input() <- txn
-
- return nil
+ select {
+ case <-m.errCh:
+ return m.err
+ case m.loader.Input() <- txn:
+ return nil
+ }
}
// Close implements Syncer interface
@suzaku Nice suggestion! It works for |
One possible way is to encapsulate the enqueueing of Maybe we can do that in a separate PR. For this problem, can we add a test case to prove that we have solved the hanging problem? |
/run-integration-tests tidb=release-3.0 tikv=release-3.0 pd=release-3.0 |
/run-all-tests tidb=release-3.0 tikv=release-3.0 pd=release-3.0 |
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.
LGTM
What problem does this PR solve?
TOOL-1579
When loader meets some errors in
loader.Run
it will quit immediately. But if there is some other functions trying to syncing txns toloader.input
they may get blocked. This problem is similar to #714.What is changed and how it works?
Add
select
in mysql dsyncer. When loader finishedloader.run
,mysql.Error()
will be activated which can avoid block.Check List
Tests
Code changes
Side effects
Related changes