Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-26914

ThriftServer scheduler pool may be unpredictably when using fair schedule mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4.0
    • 3.0.0
    • SQL
    • None

    Description

      When using fair scheduler mode for thrift server, we may have unpredictable result.

      val pool = sessionToActivePool.get(parentSession.getSessionHandle)
          if (pool != null) {
            sqlContext.sparkContext.setLocalProperty(SparkContext.SPARK_SCHEDULER_POOL, pool)
          }
      

      Here is an example:
      We have some query will use default pool, however it submit to 'normal' pool.

      I changed code and add some log.Got some strange result.

      Then i found out that the localProperties of SparkContext may has unpredictable result when call setLocalProperty. And since thriftserver use thread pool to execute queries, it will trigger this bug sometimes.

      /**
         * Set a local property that affects jobs submitted from this thread, such as the Spark fair
         * scheduler pool. User-defined properties may also be set here. These properties are propagated
         * through to worker tasks and can be accessed there via
         * [[org.apache.spark.TaskContext#getLocalProperty]].
         *
         * These properties are inherited by child threads spawned from this thread. This
         * may have unexpected consequences when working with thread pools. The standard java
         * implementation of thread pools have worker threads spawn other worker threads.
         * As a result, local properties may propagate unpredictably.
         */
        def setLocalProperty(key: String, value: String) {
          if (value == null) {
            localProperties.get.remove(key)
          } else {
            localProperties.get.setProperty(key, value)
          }
        }
      

      Attachments

        1. 26914-01.png
          15 kB
          zhoukang
        2. 26914-02.png
          174 kB
          zhoukang
        3. 26914-03.png
          121 kB
          zhoukang

        Issue Links

          Activity

            People

              cane zhoukang
              cane zhoukang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: