-
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
kv: merge batch get results to fix insert ignore in a transaction block #6215
Conversation
@jackysp |
kv/txn.go
Outdated
// BatchGetValues gets values in batch. | ||
// The values from buffer in transaction and the values from the storage node are merged together. | ||
func BatchGetValues(txn Transaction, keys []Key) (map[string][]byte, error) { | ||
bufferValues := make(map[string][]byte, len(keys)) |
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.
Using a keys slice and a values slice has a lower cost.
PTAL @coocood |
LGTM |
/run-all-tests |
continue | ||
} | ||
storageValues[string(key)] = bufferValues[i] | ||
} |
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 do CheckVisibility(txn.startTS)
?
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.
In (s *tikvSnapshot) BatchGet
, it is already been checked.
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.
Ignore it.
We do it in BatchGet
.
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
Merge the batch get results with buffer store to fix insert ignore bug when it is in a transaction block.
PTAL @coocood