ruromero / cloudevents-player

Cloudevents Player tool
Apache License 2.0
40 stars 15 forks source link

RESTEASY002020: Unhandled asynchronous exception, sending back 500: java.lang.NullPointerException #55

Closed pnivanov closed 1 year ago

pnivanov commented 1 year ago

After running for some time, cludevents-player UI stops working. The error that is visible in the browser console is the following:

Screenshot 2023-03-01 at 15 36 31

When I check the pod logs, I can see it is full of the following errors:

2023-03-01 14:34:50,799 ERROR [org.jbo.res.res.i18n] (ForkJoinPool.commonPool-worker-9) RESTEASY002020: Unhandled asynchronous exception, sending back 500: java.lang.NullPointerException
    at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
    at java.util.TimSort.sort(TimSort.java:234)
    at java.util.Arrays.sort(Arrays.java:1515)
    at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:353)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:503)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at com.redhat.syseng.tools.cloudevents.service.MessageService.newEvent(MessageService.java:46)
    at com.redhat.syseng.tools.cloudevents.service.MessageService.receive(MessageService.java:39)
    at com.redhat.syseng.tools.cloudevents.service.MessageService_ClientProxy.receive(MessageService_ClientProxy.zig:213)
    at com.redhat.syseng.tools.cloudevents.resources.MessageReceiverResource.lambda$receive$0(MessageReceiverResource.java:45)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:497)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)

I am attaching the full log here: cloudevents-player.log

ruromero commented 1 year ago

@pnivanov are you deploying it as a Knative service? If so, my guess is that after some time without active HTTP request the service is scaled down to zero and that causes the Websocket to fail. To prevent that behaviour you can set the minimum size to 1.

https://knative.dev/docs/serving/autoscaling/scale-bounds/#lower-bound

Let me know if this is not the case.

ruromero commented 1 year ago

Also make sure you're using the latest version of the player. quay.io/ruben/cloudevents-player:v1.3 or quay.io/ruben/cloudevents-player:latest

ruromero commented 1 year ago

I've been running it for ~30 minutes without any problem. In the example deployment the minScale is set to 1 so if you're using it that shouldn't be the problem.

pnivanov commented 1 year ago

@ruromero Yes, I am deploying it as Knative service. But the service is configured with minScale=1:

spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/min-scale: "1"

It starts failing after more than a day. I will update the issue when it gets reproduced again.

pnivanov commented 1 year ago

Here is my entire yaml:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: cloudevents-player
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/min-scale: "1"
    spec:
      containers:
        - image: ruromero/cloudevents-player:latest
          env:
            - name: BROKER_URL
              value: http://broker-ingress.knative-eventing.svc.cluster.local/default/default

I can see that in your example there is an extra environment variable, that I don't have:

            - name: PLAYER_MODE
              value: KNATIVE

Would it help if I set it? If it is necessary, the Knative tutorial should be updated: https://knative.dev/docs/getting-started/first-source/

ruromero commented 1 year ago

I will send a PR to that documentation as it is very outdated. It is using docker images which are very old. Try to use quay.io/ruben/cloudevents-player instead

pnivanov commented 1 year ago

Thank you, Ruben! Will redeploy from quay.io and use your example deployment yaml instead.

pnivanov commented 1 year ago

Unfortunately I cannot deploy quay.io/ruben/cloudevents-player:latest The deployment fails with:

Message:               Container failed with: qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

I suspect the reason is that I am using Apple M1 arm processor and qemu emulation... Do you have native arm build?

ruromero commented 1 year ago

I tried to build multi-arch images but apparently it didn't work. I will revisit this part when I find some time, thanks for letting me know. You can however build the image yourself if you want.

ruromero commented 1 year ago

@pnivanov try now, I have tested the arm64 image it on my Raspberry 4 and it works. See #60

ruromero commented 1 year ago

I have created https://github.com/knative/docs/pull/5486