refact: enhance cache invalidation of the partition -> leader shard in ClientCache (#2588)

This commit is contained in:
haohao0103 2024-07-15 23:07:30 +08:00 committed by GitHub
parent bd83741f24
commit 85e096698a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -275,6 +275,7 @@ public class ClientCache {
groups = new ConcurrentHashMap<>();
stores = new ConcurrentHashMap<>();
caches = new ConcurrentHashMap<>();
initialized.set(false);
}
public Shard getLeader(int partitionId) {

View File

@ -461,7 +461,9 @@ public class PDClient {
*/
public KVPair<Metapb.Partition, Metapb.Shard> getPartition(String graphName, byte[] key) throws
PDException {
KVPair<Metapb.Partition, Metapb.Shard> partShard = cache.getPartitionByKey(graphName, key);
KVPair<Metapb.Partition, Metapb.Shard> partShard =
this.getPartitionByCode(graphName, PartitionUtils.calcHashcode(key));
partShard = getKvPair(graphName, key, partShard);
return partShard;
}