Skip to content

Flaky-test: Out-of-memory error in Broker Group 3 unit tests #17714

Description

@lhotari

Search before asking

  • I searched in the issues and found nothing similar.

Example failure

https://github.com/apache/pulsar/actions/runs/3080021439/jobs/4976960591#step:10:1323

Exception stacktrace

Error:  org.apache.maven.surefire.booter.SurefireBooterForkException: ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
  Error:  Command was /bin/sh -c cd /home/runner/work/pulsar/pulsar/pulsar-broker && /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -XX:+ExitOnOutOfMemoryError -Xmx1G -XX:+UseZGC -Dpulsar.allocator.pooled=true -Dpulsar.allocator.leak_detection=Advanced -Dpulsar.allocator.exit_on_oom=false -Dpulsar.allocator.out_of_memory_policy=FallbackToHeap -Dio.netty.tryReflectionSetAccessible=true --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED -jar /home/runner/work/pulsar/pulsar/pulsar-broker/target/surefire/surefirebooter6285857233189930100.jar /home/runner/work/pulsar/pulsar/pulsar-broker/target/surefire 2022-09-19T05-08-13_830-jvmRun2 surefire8224364011378699953tmp surefire_110551185120820105364tmp
  Error:  Error occurred in starting fork, check output in log
  Error:  Process Exit Code: 3
  Error:  	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.awaitResultsDone

heap dump uploaded to https://transfer.sh/whRQiJ/Unit-BROKER_GROUP_3-heapdump.zip
thread dump extracted from heap dump https://gist.github.com/lhotari/6f056f053ca9a617692d24cde86bbd87

about 280 MB memory kept in mocks which are hanging on loadbalancer threads:
image

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. lhotari commented on Sep 19, 2022

    @lhotari
    MemberAuthor

    I checked this and found a bug pattern in the tests. There are quite a few locations where the test code calls "setup" or "internalSetup" without first cleaning up previous state and cleaning up resources. I started changes in this branch, but there's a problem to be solved so that the ServiceConfiguration could be modified in a test. It would be good to have that explicitly handled in the test framework.

  2. lhotari commented on Sep 27, 2022

    @lhotari
    MemberAuthor

    This appears to be a separate issue than #17655 .

    The reason why this happens is simply that Mockito tracks each invocation of mocks / spies. I'll push a fix soon.

  3. self-assigned this
    on Sep 27, 2022
  4. lhotari commented on Sep 27, 2022

    @lhotari
    MemberAuthor

    Analysis of stored invocations: https://gist.github.com/lhotari/520428ca36779217a633b32f105db073

    method,invocationCount,
    public org.apache.pulsar.broker.resources.PulsarResources org.apache.pulsar.broker.PulsarService.getPulsarResources(),471647,
    public org.apache.pulsar.broker.ServiceConfiguration org.apache.pulsar.broker.PulsarService.getConfiguration(),42779,
    public org.apache.pulsar.broker.service.BrokerService org.apache.pulsar.broker.PulsarService.getBrokerService(),34534,
    public org.apache.pulsar.broker.namespace.NamespaceService org.apache.pulsar.broker.PulsarService.getNamespaceService(),10334,
    public java.util.concurrent.ScheduledExecutorService org.apache.pulsar.broker.PulsarService.getExecutor(),8922,
    public org.apache.pulsar.broker.loadbalance.LeaderElectionService org.apache.pulsar.broker.PulsarService.getLeaderElectionService(),7327,
    public java.lang.String org.apache.pulsar.broker.PulsarService.getBrokerServiceUrl(),3540,
    public java.lang.String org.apache.pulsar.broker.PulsarService.getAdvertisedAddress(),1362,
    

    with https://github.com/vlsi/mat-calcite-plugin query

    select t.m as "method", count(t.m) as invocationCount from (select toString(getField(getField(i.this, 'mockitoMethod'), 'method')) as m from org.mockito.internal.verification.DefaultRegisteredInvocations r, lateral table(getValues(r.invocations)) i) as t group by 1 order by 2 desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions