Skip to content

OOM in UT testSelectByWeight #2845

Closed

Description

@biyuhao
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: master branch
  • Operating System version: macos
  • Java version: 1.8

Steps to reproduce this issue

  1. ./mvnw test -pl dubbo-cluster -Dtest=org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest

Expected Result

What do you expected from the above steps?

UT passed

Actual Result

What actually happens?

OOME thrown

If there is an exception, please attach the exception trace:

Running org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest
[29/11/18 12:24:27:027 CST] main  INFO logger.LoggerFactory: using logger: org.apache.dubbo.common.logger.log4j.Log4jLoggerAdapter
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-6"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "surefire-forkedjvm-command-thread"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "last-ditch-daemon-shutdown-thread-30sec"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-5"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-1"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-10"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-7"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-9"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-2"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-3"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-8"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-4"
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 158.071 sec <<< FAILURE! - in org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest
org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest  Time elapsed: 145.903 sec  <<< ERROR!
java.lang.OutOfMemoryError: Java heap space


Results :

Tests in error: 
  RoundRobinLoadBalanceTest.org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest » OutOfMemory

Root cause analysis

Our mocked weightInvoker is recoding details of every single invocation which will consuming a lot of memory. please ref Mockito throws an OutOfMemoryError on a simple test
The maximum heap size of our test process specified in pom.xml is 512MB which is not enough for this test case (RoundRobinLoadBalanceTest#testSelectByWeight)

Solutions

  • Option A, simply increase -Xmx in argline
  • Option B, mock weightInvoker$ with MockSettings stubOnly

In my view, if the invoking details is not that necessary we can choose Option B.
And I will send a PR later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions