-
Notifications
You must be signed in to change notification settings - Fork 637
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: solve data race #234
fix: solve data race #234
Conversation
Jeremy-Run
commented
Jul 28, 2023
- solve data race
- modify annotation
Thanks, then |
yes |
}() | ||
} | ||
wg.Wait() | ||
} |
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.
Add some assertions after the concurrent put is done.
like Assert.equal(100, KeysNum)
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.
ok
batch.go
Outdated
@@ -16,7 +16,7 @@ import ( | |||
// If readonly is false, you can use Put and Delete method to write data to the batch. | |||
// The data will be written to the database when you call Commit method. | |||
// | |||
// Batch is not a transaction, it does not guarantee isolation. | |||
// Batch is not a transaction, it does not guarantee isolation(only guarantee read committed). |
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.
It`s not a very accurate description, actually, the isolation is Serializable because we have a global lock.
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 was thinking about this problem just now, I will delete it.
@@ -174,8 +174,8 @@ func TestDB_Merge_6_Appending(t *testing.T) { | |||
for i := 0; i < 10000; i++ { | |||
key := utils.GetTestKey(rand.Int()) | |||
m.Store(string(key), struct{}{}) | |||
err = db.Put(key, utils.RandomValue(128)) | |||
assert.Nil(t, err) | |||
e := db.Put(key, utils.RandomValue(128)) |
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.
Is this necessary?
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.
Yes, it's necessary. There are two data race points, this is one.
Thanks |