Coder Social home page Coder Social logo

Channel stop receiving about jox HOT 9 CLOSED

svenkubiak avatar svenkubiak commented on September 22, 2024
Channel stop receiving

from jox.

Comments (9)

adamw avatar adamw commented on September 22, 2024 1

Thanks for the update :) I did run an overnight test as well, but didn't find anything.

Maybe you are experiencing thread pinning, as part of your blocking call? This can be traced by adding -Djdk.tracePinnedThreads=full (see e.g. https://todd.ginsberg.com/post/java/virtual-thread-pinning/)

from jox.

adamw avatar adamw commented on September 22, 2024

Hm that's very suspicious. No, there's nothing time-based in the code. I know it's hard to reproduce, but the Channel.toString dumps a lot of internal representation information, which might help to debug such issues.

Is there some specific pattern of production/consumption that you are using, that might help to reproduce the problem?

from jox.

svenkubiak avatar svenkubiak commented on September 22, 2024

Let me try the Channel.toString. I have also added a check for isClosedForReceive() - was only checking isClosedForSend so far.

Using jox more or less out of the examples with a little wrapper around it - see:
https://github.com/svenkubiak/mangooio/blob/feature/8.5.0/mangooio-core/src/main/java/io/mangoo/async/EventBusHandler.java

from jox.

adamw avatar adamw commented on September 22, 2024

Indeed this seems like rather ordinary usage

In addition to the testsuite (which includes benchmarks sending many messages), I'm also running a simple two-thread send-receive loop locally, so far 47298000000 messages have successfully been sent & received ;)

If you'd have some more information, that would be great.

from jox.

svenkubiak avatar svenkubiak commented on September 22, 2024

I am quite sure that this is caused by the virtual thread that my receive() call is wrapped in. Looks like this is not intended for a blocking call. I have made some adjustments in my code and going to run further tests. But I am absolutely convince that this it not related to jox at all.

from jox.

svenkubiak avatar svenkubiak commented on September 22, 2024

While I was quite certain that switching from a virtual thread to a platform thread would fix my issue, unfortunately it didn't. Stopped receiving after around 12 hours as before. While I was further investigating this I noticed that in the doReceive() method there is a check regarding the segment id

if (segment.getId() != id)

If this would match equal, then doReceive would end up in an infinite loop not receiving. What would be the situations when this could happen?

As this is not mentioned in the readme, your recommendation for have a constant received would be to put the receive() in an infinite loop, right? So something like this:

Thread.ofVirtual().start(() -> {
    try {
        while(true) {
                var payload = channel.receive();
                //handle payload
        }
    } catch (Exception e) { //NOSONAR
        ...
    }
});

I have adjusted my implementation again and doing additional tests now.

from jox.

adamw avatar adamw commented on September 22, 2024

If you are referring to this line, on the next iteration it will re-read the receiveSegment value, and it should already be move forward. This might only happen if there are concurrent receives happening - which I don't think is the case here (when another recevie() moves forward the segment). The segment is moved forward in findAndMoveForward.

Yes, the loop looks right. Maybe try catching & logging a Throwable, so that e.g. OutOfMemoryError is also discovered? Or better, installing an uncaught exception handler.

Did you try capturing the stack trace?

from jox.

svenkubiak avatar svenkubiak commented on September 22, 2024

If you are referring to this line, on the next iteration it will re-read the receiveSegment value, and it should already be move forward. This might only happen if there are concurrent receives happening - which I don't think is the case here (when another recevie() moves forward the segment). The segment is moved forward in findAndMoveForward.

Yes, the loop looks right. Maybe try catching & logging a Throwable, so that e.g. OutOfMemoryError is also discovered? Or better, installing an uncaught exception handler.

Did you try capturing the stack trace?

Yes, I did. And after a lot of digging, it turned out to be an OutOfMemoryError Exception in an InfluxDB connection which was part of the what the receive() was handling. That was one of the stranges behaviours I have seen. The whole application kept behaving normal in some parts.

Thanks for your support!

from jox.

adamw avatar adamw commented on September 22, 2024

Ah, good to hear it's resolved :)

from jox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.