Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Concurrent operations on directory tree may cause Quota updates and verification to not be thread-safe.

      For example: 

      1. Supposing there is directory /a/b and quota is on inode a and b
      2. There are some directories and files under /a/b, such as: /a/b/c/d1, /a/b/d/f1.txt
      3. Supposing there is a create operation under /a/b/c/d1 and there is a addBlock operation on /a/b/d/f1.txt
      4. These two operations can be handled concurrently by namenode
      5. They will update the quota on inode a concurrently since these operations just hold the read lock of the inode a and b.
      6. so we should make quota-related thread safe.

       

      There are two solutions to make quota-related thread safe。

      Solution one: Hold the write lock of the first iNode with Quota set when resolvePath

      • Directly hold the write lock of iNode a so that all operations involving subtree /a can be handled safety.
      • Due to lower concurrency, maximum improvements cannot be achieved.
      • But the implementation is simple and straightforward.

      Solution two: Lock all QuotaFeatures during quota verification or update

      • Still hold the read lock of iNode a and b
      • Lock all QuotaFeatures involved in this operations, when validating or updating quotas.
      • Maximum improvements can be achieved.
      • But the implementation is a little complex
        • Add a lock for each QuotaFeature
        • Acquire locks for all involving QuotaFeature

      Attachments

        Activity

          People

            xuzq_zander ZanderXu
            xuzq_zander ZanderXu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: