Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-12667

KMSClientProvider#ValueQueue does synchronous fetch of edeks in background async thread.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 3.0.0-alpha4
    • None
    • encryption, kms
    • None

    Description

      There are couple of issues in KMSClientProvider#ValueQueue.
      1.

      ValueQueue.java
        private final LoadingCache<String, LinkedBlockingQueue<E>> keyQueues;
        // Stripped rwlocks based on key name to synchronize the queue from
        // the sync'ed rw-thread and the background async refill thread.
        private final List<ReadWriteLock> lockArray =
            new ArrayList<>(LOCK_ARRAY_SIZE);
      

      It hashes the key name into 16 buckets.
      In the code chunk below,

      ValueQueue.java
      public List<E> getAtMost(String keyName, int num) throws IOException,
            ExecutionException {
           ...
           ...
               readLock(keyName);
              E val = keyQueue.poll();
              readUnlock(keyName);
           ...
        }
      
        private void submitRefillTask(final String keyName,
            final Queue<E> keyQueue) throws InterruptedException {
                    ...
                    ...
                    writeLock(keyName); // It holds the write lock while the key is being asynchronously fetched. So the read requests for all the keys that hashes to this bucket will essentially be blocked.
                    try {
                      if (keyQueue.size() < threshold && !isCanceled()) {
                        refiller.fillQueueForKey(name, keyQueue,
                            cacheSize - keyQueue.size());
                      }
                   ...
                    } finally {
                      writeUnlock(keyName);
                    }
                  }
        }
      

      According to above code chunk, if two keys (lets say key1 and key2) hashes to the same bucket (between 1 and 16), then if key1 is asynchronously being refetched then all the getKey for key2 will be blocked.

      2. Due to stripped rw locks, the asynchronous behavior of refill keys is now synchronous to other handler threads.

      I understand that locks were added so that we don't kick off multiple asynchronous refilling thread for the same key.

      Attachments

        1. HDFS-12667-001.patch
          22 kB
          Rushabh Shah
        2. HDFS-12667-002.patch
          22 kB
          Rushabh Shah

        Issue Links

          Activity

            People

              shahrs87 Rushabh Shah
              shahrs87 Rushabh Shah
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: