This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-3.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.4 by this push:
     new 2eb603c09fb5 [SPARK-46577][SQL] HiveMetastoreLazyInitializationSuite 
leaks hive's SessionState
2eb603c09fb5 is described below

commit 2eb603c09fb5e81ae24f4e43a17fa45fb071c358
Author: Kent Yao <y...@apache.org>
AuthorDate: Wed Jan 3 05:54:57 2024 -0800

    [SPARK-46577][SQL] HiveMetastoreLazyInitializationSuite leaks hive's 
SessionState
    
    ### What changes were proposed in this pull request?
    
    The upcoming tests with the new hive configurations will have no effect due 
to the leaked SessionState.
    
    ```
    06:21:12.848 pool-1-thread-1 INFO ThriftServerWithSparkContextInHttpSuite: 
Trying to start HiveThriftServer2: mode=http, attempt=0
    ....
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service:OperationManager 
is inited.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service:SessionManager 
is inited.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service: CLIService is 
inited.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: 
Service:ThriftBinaryCLIService is inited.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service: HiveServer2 is 
inited.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service:OperationManager 
is started.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service:SessionManager 
is started.
    06:21:12.851 pool-1-thread-1 INFO AbstractService: Service: CLIService is 
started.
    06:21:12.852 pool-1-thread-1 INFO AbstractService: 
Service:ThriftBinaryCLIService is started.
    06:21:12.852 pool-1-thread-1 INFO ThriftCLIService: Starting 
ThriftBinaryCLIService on port 10000 with 5...500 worker threads
    06:21:12.852 pool-1-thread-1 INFO AbstractService: Service:HiveServer2 is 
started.
    ```
    
    As the logs above revealed, ThriftServerWithSparkContextInHttpSuite started 
the ThriftBinaryCLIService instead of the ThriftHttpCLIService. This is because 
in HiveClientImpl, the new configurations are only applied to hive conf during 
initializing but not for existing ones.
    
    This cause ThriftServerWithSparkContextInHttpSuite retrying or even 
aborting.
    
    ### Why are the changes needed?
    
    Fix flakiness in tests
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    ### How was this patch tested?
    
    ran tests locally with the hive-thriftserver module locally,
    ### Was this patch authored or co-authored using generative AI tooling?
    no
    
    Closes #44578 from yaooqinn/SPARK-46577.
    
    Authored-by: Kent Yao <y...@apache.org>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
    (cherry picked from commit 605fecd22cc18fc9b93fb26d4aa6088f5a314f92)
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../spark/sql/hive/HiveMetastoreLazyInitializationSuite.scala       | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreLazyInitializationSuite.scala
 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreLazyInitializationSuite.scala
index b8739ce56e41..cb85993e5e09 100644
--- 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreLazyInitializationSuite.scala
+++ 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreLazyInitializationSuite.scala
@@ -17,6 +17,8 @@
 
 package org.apache.spark.sql.hive
 
+import org.apache.hadoop.hive.ql.metadata.Hive
+import org.apache.hadoop.hive.ql.session.SessionState
 import org.apache.logging.log4j.LogManager
 import org.apache.logging.log4j.core.Logger
 
@@ -69,6 +71,10 @@ class HiveMetastoreLazyInitializationSuite extends 
SparkFunSuite {
     } finally {
       Thread.currentThread().setContextClassLoader(originalClassLoader)
       spark.sparkContext.setLogLevel(originalLevel.toString)
+      SparkSession.clearActiveSession()
+      SparkSession.clearDefaultSession()
+      SessionState.detachSession()
+      Hive.closeCurrent()
       spark.stop()
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to