-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
meta: fix err check #22995
Merged
Merged
meta: fix err check #22995
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d169b99
fix err check
Tjianke 1ff523a
fix format
Tjianke e8847dd
fix err check
Tjianke 592325f
fix err check
Tjianke 5a8eedd
Merge branch 'master' into fixErrCheckMeta
ti-chi-bot 53eeee3
Merge branch 'master' into fixErrCheckMeta
ti-chi-bot b3f69b4
Merge branch 'master' into fixErrCheckMeta
ti-chi-bot c84d6cf
Merge branch 'master' into fixErrCheckMeta
ti-chi-bot b98ea91
Merge branch 'master' into fixErrCheckMeta
ti-chi-bot 9feede4
Merge branch 'master' into fixErrCheckMeta
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,17 @@ func (s *testSuite) TestMeta(c *C) { | |
defer testleak.AfterTest(c)() | ||
store, err := mockstore.NewMockStore() | ||
c.Assert(err, IsNil) | ||
defer store.Close() | ||
defer func() { | ||
// to fix: close fails | ||
_ = store.Close() | ||
}() | ||
|
||
txn, err := store.Begin() | ||
c.Assert(err, IsNil) | ||
defer txn.Rollback() | ||
defer func() { | ||
// to fix : occasion failure | ||
_ = txn.Rollback() | ||
}() | ||
|
||
t := meta.NewMeta(txn) | ||
|
||
|
@@ -275,23 +281,30 @@ func (s *testSuite) TestSnapshot(c *C) { | |
defer testleak.AfterTest(c)() | ||
store, err := mockstore.NewMockStore() | ||
c.Assert(err, IsNil) | ||
defer store.Close() | ||
defer func() { | ||
err := store.Close() | ||
c.Assert(err, IsNil) | ||
}() | ||
|
||
txn, _ := store.Begin() | ||
m := meta.NewMeta(txn) | ||
m.GenGlobalID() | ||
_, err = m.GenGlobalID() | ||
c.Assert(err, IsNil) | ||
n, _ := m.GetGlobalID() | ||
c.Assert(n, Equals, int64(1)) | ||
txn.Commit(context.Background()) | ||
err = txn.Commit(context.Background()) | ||
c.Assert(err, IsNil) | ||
|
||
ver1, _ := store.CurrentVersion(oracle.GlobalTxnScope) | ||
time.Sleep(time.Millisecond) | ||
txn, _ = store.Begin() | ||
m = meta.NewMeta(txn) | ||
m.GenGlobalID() | ||
_, err = m.GenGlobalID() | ||
c.Assert(err, IsNil) | ||
n, _ = m.GetGlobalID() | ||
c.Assert(n, Equals, int64(2)) | ||
txn.Commit(context.Background()) | ||
err = txn.Commit(context.Background()) | ||
c.Assert(err, IsNil) | ||
|
||
snapshot := store.GetSnapshot(ver1) | ||
snapMeta := meta.NewSnapshotMeta(snapshot) | ||
|
@@ -331,12 +344,18 @@ func (s *testSuite) TestDDL(c *C) { | |
defer testleak.AfterTest(c)() | ||
store, err := mockstore.NewMockStore() | ||
c.Assert(err, IsNil) | ||
defer store.Close() | ||
defer func() { | ||
err := store.Close() | ||
c.Assert(err, IsNil) | ||
}() | ||
|
||
txn, err := store.Begin() | ||
c.Assert(err, IsNil) | ||
|
||
defer txn.Rollback() | ||
defer func() { | ||
// to fix: codeText:"kv:8024", message:"invalid transaction" | ||
_ = txn.Rollback() | ||
}() | ||
|
||
t := meta.NewMeta(txn) | ||
|
||
|
@@ -437,7 +456,8 @@ func (s *testSuite) TestDDL(c *C) { | |
c.Assert(job.ID, Greater, lastID) | ||
lastID = job.ID | ||
arg1 := "" | ||
job.DecodeArgs(&arg1) | ||
err := job.DecodeArgs(&arg1) | ||
c.Assert(err, IsNil) | ||
if job.ID == historyJob1.ID { | ||
c.Assert(*(job.Args[0].(*string)), Equals, historyJob1.Args[0]) | ||
} else { | ||
|
@@ -469,7 +489,10 @@ func (s *testSuite) TestDDL(c *C) { | |
// Test for add index job. | ||
txn1, err := store.Begin() | ||
c.Assert(err, IsNil) | ||
defer txn1.Rollback() | ||
defer func() { | ||
// to fix : occasion failure | ||
_ = txn1.Rollback() | ||
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. Could you check this code too? 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. Done. |
||
}() | ||
|
||
m := meta.NewMeta(txn1, meta.AddIndexJobListKey) | ||
err = m.EnQueueDDLJob(job) | ||
|
@@ -498,11 +521,17 @@ func (s *testSuite) BenchmarkGenGlobalIDs(c *C) { | |
defer testleak.AfterTest(c)() | ||
store, err := mockstore.NewMockStore() | ||
c.Assert(err, IsNil) | ||
defer store.Close() | ||
defer func() { | ||
err := store.Close() | ||
c.Assert(err, IsNil) | ||
}() | ||
|
||
txn, err := store.Begin() | ||
c.Assert(err, IsNil) | ||
defer txn.Rollback() | ||
defer func() { | ||
err := txn.Rollback() | ||
c.Assert(err, IsNil) | ||
}() | ||
|
||
t := meta.NewMeta(txn) | ||
|
||
|
@@ -519,11 +548,17 @@ func (s *testSuite) BenchmarkGenGlobalIDOneByOne(c *C) { | |
defer testleak.AfterTest(c)() | ||
store, err := mockstore.NewMockStore() | ||
c.Assert(err, IsNil) | ||
defer store.Close() | ||
defer func() { | ||
err := store.Close() | ||
c.Assert(err, IsNil) | ||
}() | ||
|
||
txn, err := store.Begin() | ||
c.Assert(err, IsNil) | ||
defer txn.Rollback() | ||
defer func() { | ||
err := txn.Rollback() | ||
c.Assert(err, IsNil) | ||
}() | ||
|
||
t := meta.NewMeta(txn) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need to fix 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.
I am not very familiar with the code in meta package, but I assume
store.Close()
should be err nil, however it returned err in this line. So either we ignore the err or somewhat fix the test?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.
Look at this code, I think we can remove line57-60. Because we commit this
txn
on line.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.
Removed and test passed.