Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-19261

Avro SerDe's InstanceCache should not be synchronized on retrieve

Log workAgile BoardRank to TopRank to BottomBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      In HIVE-16175, upstream made a patch to fix the thread safety issue in AvroSerDe's InstanceCache. This fix made the retrieve method in InstanceCache synchronized. While it should make InstanceCache thread-safe, making retrieve synchronized for the cache can be expensive in highly concurrent environment like Spark, as multiple threads need to be synchronized on entering the entire retrieve method.

      We are proposing another way to fix this thread safety issue by making the underlying map of InstanceCache as ConcurrentHashMap. Ideally, we can use atomic computeIfAbsent in the retrieve method to avoid synchronizing the entire method.

      While computeIfAbsent is only available on java 8 and java 7 is still supported in Hive,
      we use a pattern to simulate the behavior of computeIfAbsent. In the future, we should move to computeIfAbsent when Hive requires java 8.

      Attachments

        1. HIVE-19261.1.patch
          2 kB
          Fangshi Li

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            humanoid Alexey Diomin Assign to me
            shengzhixia Fangshi Li
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 2h 40m
              2h 40m

              Slack

                Issue deployment