-
Notifications
You must be signed in to change notification settings - Fork 118
Closed
Labels
Description
Bug Report
1. Describe the bug
doCommitSecondaryKeysWithRetry will groups keys by region and then commit the whole regionstores's keys.
But the Pair<TiRegion, TiStore> in Map<Pair<TiRegion, TiStore>, List<ByteString>> groupKeyMap = groupResult.getGroupsResult(); does not override the hashcode and equals method. Thus, every time we want to add a new key to List<ByteString>, we fail to find the correct Pair<TiRegion, TiStore> and create a new one.
| GroupKeyResult groupResult = this.groupKeysByRegion(keys, size, backOffer); |
private void doCommitSecondaryKeysWithRetry(
BackOffer backOffer, ByteString[] keys, int size, long commitTs)
throws TiBatchWriteException {
if (keys == null || keys.length == 0 || size <= 0) {
return;
}
// groups keys by region
GroupKeyResult groupResult = this.groupKeysByRegion(keys, size, backOffer);
List<BatchKeys> batchKeyList = new ArrayList<>();
Map<Pair<TiRegion, TiStore>, List<ByteString>> groupKeyMap = groupResult.getGroupsResult();
for (Map.Entry<Pair<TiRegion, TiStore>, List<ByteString>> entry : groupKeyMap.entrySet()) {
TiRegion tiRegion = entry.getKey().first;
TiStore store = entry.getKey().second;
this.appendBatchBySize(batchKeyList, tiRegion, store, entry.getValue(), false, null);
}
for (BatchKeys batchKeys : batchKeyList) {
doCommitSecondaryKeySingleBatchWithRetry(backOffer, batchKeys, commitTs);
}
}
This bug will cause commit 1 record every time you commit secondary keys
2. Minimal reproduce step (Required)
3. What did you see instead (Required)
4. What did you expect to see? (Required)
5. What are your Java Client and TiKV versions? (Required)
- Client Java:
- TiKV: