gohbase icon indicating copy to clipboard operation
gohbase copied to clipboard

findRegion should a lock to avoid cache avalanche

Open xpineal opened this issue 3 years ago • 0 comments

If there are a lot of RPC request to a same table, but the region information not in cache.

func (c *client) findRegion(ctx context.Context, table, key []byte) (hrpc.RegionInfo, error) {
	//get or create table related lcck in hash
	var tableName = string(table)
	var iLock, _ = c.tMetaLockHash.LoadOrStore(tableName, &sync.Mutex{})
	var lock = iLock.(*sync.Mutex)
	locker.Lock()
	defer locker.Unlock()

	if reg := c.getRegionFromCache(table, key); reg != nil {
		return reg, nil
	}
        .....

xpineal avatar Mar 04 '21 08:03 xpineal