Skip to content

Conversation

@HeartSaVioR
Copy link
Contributor

@HeartSaVioR HeartSaVioR commented Jul 8, 2020

What changes were proposed in this pull request?

This patch changes the HiveSessionImplSuite to mock instances "before" initializing HiveSessionImpl, to avoid possible classloader issue.

Why are the changes needed?

The failures of HiveSessionImplSuite always come from classloader issue. While I don't have clear idea what is happening, there's no part possibly dealing with classloader, except initializing HiveSessionImpl. We can move the mock initializations earlier than initialing HiveSessionImpl so that it can avoid possible classloader issue.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Verified with multiple triggers of Jenkins builds

@HeartSaVioR HeartSaVioR changed the title [WIP] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl [WIP][SPARK-XXXXX] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl Jul 8, 2020
@HeartSaVioR HeartSaVioR marked this pull request as draft July 8, 2020 12:40
@HeartSaVioR
Copy link
Contributor Author

Rationalization: the failures always come from classloader issue;

sbt.ForkMain$ForkError: org.mockito.exceptions.base.MockitoException: 
ClassCastException occurred while creating the mockito mock :
  class to mock : 'org.apache.hive.service.cli.session.SessionManager', loaded by classloader : 'sun.misc.Launcher$AppClassLoader@2d6d8735'
  created class : 'org.mockito.codegen.SessionManager$MockitoMock$2028320452', loaded by classloader : 'net.bytebuddy.dynamic.loading.MultipleParentClassLoader@4058f9df'
  proxy instance class : 'org.mockito.codegen.SessionManager$MockitoMock$2028320452', loaded by classloader : 'net.bytebuddy.dynamic.loading.MultipleParentClassLoader@4058f9df'
  instance creation by : ObjenesisInstantiator

You might experience classloading issues, please ask the mockito mailing-list.

	at org.apache.spark.sql.hive.thriftserver.HiveSessionImplSuite.beforeAll(HiveSessionImplSuite.scala:44)
	at org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:212)
	at org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)
	at org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)
	at org.apache.spark.SparkFunSuite.run(SparkFunSuite.scala:59)
	at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:317)
	at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:510)
	at sbt.ForkMain$Run$2.call(ForkMain.java:296)
	at sbt.ForkMain$Run$2.call(ForkMain.java:286)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: sbt.ForkMain$ForkError: java.lang.ClassCastException: org.mockito.codegen.SessionManager$MockitoMock$2028320452 cannot be cast to org.mockito.internal.creation.bytebuddy.MockAccess
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:48)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
	at org.mockito.Mockito.mock(Mockito.java:1908)
	at org.mockito.Mockito.mock(Mockito.java:1817)
	... 13 more

while I don't have clear idea what is happening, there's no part possibly dealing with classloader, except initializing HiveSessionImpl (only suspect, no clear evidence yet). This patch is to verify the idea that mocking instances before initializing HiveSessionImpl would avoid the classloader issue.

It's less flaky then CliSuite and only checked once per build, so to verify multiple times I just create 9 duplicated suites to test 10 times per build.

@HeartSaVioR
Copy link
Contributor Author

retest this, please

2 similar comments
@HeartSaVioR
Copy link
Contributor Author

retest this, please

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125365 has finished for PR 29039 at commit 3d0d7e8.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125363 has finished for PR 29039 at commit 3d0d7e8.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125371 has started for PR 29039 at commit 9c48467.

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125375 has started for PR 29039 at commit 9c48467.

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125361 has finished for PR 29039 at commit 3d0d7e8.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125368 has finished for PR 29039 at commit 9c48467.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HeartSaVioR
Copy link
Contributor Author

Summary of 4 builds:

125361 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125361/testReport/)

HiveSessionImplSuite(s) passed

125368 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125368/testReport/)

HiveSessionImplSuite(s) passed

125371 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125371/testReport/)

HiveSessionImplSuite(s) passed

125375 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125375/testReport/)

HiveSessionImplSuite(s) passed

I'll trigger more builds to confirm, and once the new builds also pass HiveSessionImplSuite(s), turn the PR to be ready to review.

@HeartSaVioR
Copy link
Contributor Author

retest this, please

6 similar comments
@HeartSaVioR
Copy link
Contributor Author

retest this, please

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@HeartSaVioR
Copy link
Contributor Author

retest this, please

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125405 has finished for PR 29039 at commit 9c48467.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 9, 2020

Test build #125410 has finished for PR 29039 at commit 9c48467.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 9, 2020

Test build #125416 has finished for PR 29039 at commit 9c48467.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 9, 2020

Test build #125412 has finished for PR 29039 at commit 9c48467.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 9, 2020

Test build #125420 has finished for PR 29039 at commit 9c48467.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HeartSaVioR
Copy link
Contributor Author

Another summary for next set of builds

125405 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125405/testReport/)

All suites passed

125410 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125410/testReport/)

Lots of tests in CliSuite failed - #29036 is to fix flakiness, so please cross-check this and #29036 together

125416 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125416/testReport/)

All suites passed

125412 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125412/testReport/)

Lots of tests in CliSuite failed

125420 (https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/125420/testReport/)

Lots of tests in CliSuite failed

@HeartSaVioR HeartSaVioR changed the title [WIP][SPARK-XXXXX] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl [SPARK-31831] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl Jul 9, 2020
@HeartSaVioR HeartSaVioR marked this pull request as ready for review July 9, 2020 13:10
@HeartSaVioR HeartSaVioR changed the title [SPARK-31831] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl [SPARK-31831][SQL] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl Jul 9, 2020
@HeartSaVioR
Copy link
Contributor Author

cc. @dongjoon-hyun @alismess-db

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise looks good if it passes and fixes the issue.

@SparkQA
Copy link

SparkQA commented Jul 9, 2020

Test build #125473 has finished for PR 29039 at commit 9b22750.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 9, 2020

Test build #125475 has finished for PR 29039 at commit 8e083c2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member

Thank you for pinging me, @HeartSaVioR .

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Thank you, @HeartSaVioR and @srowen .
Merged to master because the affected version of SPARK-31831 is only 3.1.0.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-31831][SQL] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl [SPARK-31831][SQL][TESTS] HiveSessionImplSuite flakiness fix via mocking instances earlier than initializing HiveSessionImpl Jul 9, 2020
@HeartSaVioR
Copy link
Contributor Author

Thanks for reviewing and merging! We can port back anytime when we find the flakiness in other branches, so it should be OK to start with only master branch.

@HeartSaVioR HeartSaVioR deleted the hive-session-impl-suite-flakiness-fix branch July 9, 2020 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants