Analyse de l'exception HBase BucketAllocatorException

Récemment, les journaux WARN suivants ont été observés dans le cluster HBase:

2020-04-18 16: 17: 03,081 WARN [regionserver / xxx-BucketCacheWriter-1] bucket.BucketCache: Échec de l'allocation pour 604acc82edd349ca906939af14464bcb_175674734;
org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocatorException: allocation trop grande taille = 1114202; ajustez les tailles BucketCache hbase.bucketcache.bucket.sizes pour s'adapter si la taille semble raisonnable et que vous voulez qu'elle soit mise en cache.

Cela signifie probablement: BucketAllocator ne peut pas allouer d'espace pour le bloc car il est trop grand (taille = 1114202). Si vous souhaitez être mis en cache et pensez qu'il est raisonnable, vous pouvez ajuster le paramètre hbase.bucketcache.bucket.sizes.

Par défaut, la valeur maximale de HBase BucketCache peut mettre en cache le bloc est de 512 Ko, soit hbase.bucketcache.bucket.sizes = 5120,9216,17408,33792,41984,50176,58368,66560,99328,132096,197632,263168,394240, 525312, 14 étiquettes de taille par défaut. Si nous voulons mettre en cache un bloc plus grand, nous pouvons ajuster les paramètres à hbase.bucketcache.bucket.sizes = 5120,9216,17408,33792,41984,50176,58368,66560,99328,132096,197632,263168,394240,525312 , 1049600, 2098176, à ce moment, le bloc maximum autorisé de 2 Mo.

Jetons un bref coup d'œil au code source correspondant, les classes liées sont:
/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketAllocator.java
BucketAllocator implémente principalement l'organisation et la gestion du bucket , Allouez de l'espace mémoire au bloc.

/**
   * Allocate a block with specified size. Return the offset
   * @param blockSize size of block
   * @throws BucketAllocatorException
   * @throws CacheFullException
   * @return the offset in the IOEngine
   */
  public synchronized long allocateBlock(int blockSize) throws CacheFullException,
      BucketAllocatorException {
    assert blockSize > 0;
    BucketSizeInfo bsi = roundUpToBucketSizeInfo(blockSize);
    if (bsi == null) {
      throw new BucketAllocatorException("Allocation too big size=" + blockSize +
        "; adjust BucketCache sizes " + BlockCacheFactory.BUCKET_CACHE_BUCKETS_KEY +
        " to accomodate if size seems reasonable and you want it cached.");
    }
    long offset = bsi.allocateBlock();

    // Ask caller to free up space and try again!
    if (offset < 0)
      throw new CacheFullException(blockSize, bsi.sizeIndex());
    usedSize += bucketSizes[bsi.sizeIndex()];
    return offset;
  }

Après avoir appelé la méthode roundUpToBucketSizeInfo (), si le résultat renvoyé est nul, une BucketAllocatorException est levée. Jetez un œil à la méthode roundUpToBucketSizeInfo ():

/**
 * Round up the given block size to bucket size, and get the corresponding
 * BucketSizeInfo
*/
public BucketSizeInfo roundUpToBucketSizeInfo(int blockSize) {
	for (int i = 0; i < bucketSizes.length; ++i)
	  if (blockSize <= bucketSizes[i])
		return bucketSizeInfos[i];
	return null;
}

Cette méthode compare le blockSize entrant avec le tableau bucketSizes commençant à l'index 0. Une fois qu'il est inférieur à bucketSize [i], il alloue la taille de bucketSizeInfos [i] pour stocker le bloc.

Jetons un coup d'œil au processus d'initialisation de la baie bucketSizes:

private static final int DEFAULT_BUCKET_SIZES[] = { 4 * 1024 + 1024, 8 * 1024 + 1024,
  16 * 1024 + 1024, 32 * 1024 + 1024, 40 * 1024 + 1024, 48 * 1024 + 1024,
  56 * 1024 + 1024, 64 * 1024 + 1024, 96 * 1024 + 1024, 128 * 1024 + 1024,
  192 * 1024 + 1024, 256 * 1024 + 1024, 384 * 1024 + 1024,
  512 * 1024 + 1024 };

private final int[] bucketSizes;
BucketAllocator(long availableSpace, int[] bucketSizes)
  throws BucketAllocatorException {
  this.bucketSizes = bucketSizes == null ? DEFAULT_BUCKET_SIZES : bucketSizes;
  Arrays.sort(this.bucketSizes);
  ...
}

Comme vous pouvez le voir, si bucketSizes == null, la valeur de DEFAULT_BUCKET_SIZES est prise par défaut et le tableau est trié. L'ordre de cette étape a jeté les bases de la comparaison cyclique de l'étape précédente.

La valeur du tableau DEFAULT_BUCKET_SIZES est la valeur par défaut du paramètre hbase.bucketcache.bucket.sizes.

Scannez le code QR pour suivre le compte officiel du blogueur

Réimprimer s'il vous plaît indiquer la source! Bienvenue à prêter attention à mon compte public WeChat [notes de travail HBase]

Je suppose que tu aimes

Origine www.cnblogs.com/zpb2016/p/12756332.html
conseillé
Classement