Skip to content

Flux getting stuck in case of any java.lang.Error(OOM) #2521

@kamaljit-1991

Description

@kamaljit-1991

In parallel flux whenever there is OOM in one of the threads, the whole process is getting stuck until we kill it manually. I have created an example to simulate it. Please refer the following code:

@Test
public void test_Flux() {
    Flux.range(1, 30)
            .parallel(6)
            .runOn(Schedulers.fromExecutor(Executors.newFixedThreadPool(6)))
            .doOnNext(this::writeValues)
            .sequential()
            .blockLast();
}

private void writeValues(int val) {
    if (val == 10) {
        throw new OutOfMemoryError("failed here");
        // throw new RuntimeException("failed here");
    }
    System.out.println("the thread name is :" + Thread.currentThread().getName() + " val is :" + val);
    sleep(3);
}

private void sleep(int i) {
    try {
        Thread.sleep(i * 1000L);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException(e);
    }
}

Can we crash here instead of getting stuck?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/declinedWe feel we shouldn't currently apply this change/suggestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions