Conversation
86e80bc to
d751fcc
Compare
00f6ff1 to
2d24519
Compare
Signed-off-by: limbooverlambda <schakra1@gmail.com>
2d24519 to
767e930
Compare
| // Maintain a map of the pair and its associated ttl | ||
| let kvs = self.pairs.clone(); | ||
| let kv_pair = kvs.into_iter().map(Into::<KvPair>::into); | ||
| let kv_ttl = kv_pair.zip(self.ttls.clone()).collect::<HashMap<_, _>>(); |
There was a problem hiding this comment.
store_stream_for_keys is able to handle data of keys along with values and ttls. Mapping by Hash map is not necessary, and it's not efficient as well.
Please refer to PrewriteRequest::shards.
There was a problem hiding this comment.
Thanks for the review. Didn't realize store_stream_for_keys has this capability. Removed the HashMap to collect the ttls for the kv_pair.
There was a problem hiding this comment.
Hi @pingyu, I have made the changes. Please let me know if there's anything else I need to consider for this PR.
Signed-off-by: limbooverlambda <schakra1@gmail.com>
Signed-off-by: limbooverlambda <schakra1@gmail.com>
Signed-off-by: limbooverlambda <schakra1@gmail.com>
Signed-off-by: limbooverlambda <schakra1@gmail.com>
|
Thanks for helping me clean up this PR @pingyu. Addressed your comments. |
pingyu
left a comment
There was a problem hiding this comment.
I'm sorry I missed another suggestion in last comments. The clone in comparation should also be un-necessary.
|
|
||
| use async_trait::async_trait; | ||
| use futures::stream::BoxStream; | ||
|
|
| .zip(ttls) | ||
| .map(|(kv, ttl)| KvPairTTL(kv, ttl)) | ||
| .collect(); | ||
| kv_ttl.sort_by(|a, b| a.0.key.clone().cmp(&b.0.key)); |
There was a problem hiding this comment.
| kv_ttl.sort_by(|a, b| a.0.key.clone().cmp(&b.0.key)); | |
| kv_ttl.sort_by(|a, b| a.0.key.cmp(&b.0.key)); |
Signed-off-by: limbooverlambda <schakra1@gmail.com>
Yeah, I should have caught that. Removed. |
pingyu
left a comment
There was a problem hiding this comment.
LGTM~
Thanks for you contribution !
* fixing the shard issue with batch_put Signed-off-by: limbooverlambda <schakra1@gmail.com> * PR feedback Signed-off-by: limbooverlambda <schakra1@gmail.com> * more make check fixes Signed-off-by: limbooverlambda <schakra1@gmail.com> * removing redundant map Signed-off-by: limbooverlambda <schakra1@gmail.com> * more PR feedback Signed-off-by: limbooverlambda <schakra1@gmail.com> * slight formatting change and remove another redundant clone Signed-off-by: limbooverlambda <schakra1@gmail.com> --------- Signed-off-by: limbooverlambda <schakra1@gmail.com> Co-authored-by: Ping Yu <yuping@pingcap.com> Signed-off-by: Ping Yu <yuping@pingcap.com>
There is a bug in the client where the ttls are not properly sharded for RawBatchPuts. This essentially means that if the batch is spread across multiple regions, the ttls for the batch specific to the shard is not properly aligned. This is an issue when the request ends up in the TiKV node specific to the region and fails because of the misalignment of the
Vec<TTLs> with its correspondingVec<KvPair>. The fix was to change the sharding logic for RawBatchPutRequest so that the TTLs are aligned with the KvPair. Maintaining a mapping of the kvpair to its corresponding ttl in the Shard output.