javaspring-webfluxopenjdk-11

Webflux upload file - out of RAM or swap


I´m facing a strange issue: I´m uploading a file (about 50 MB) via WebFlux and save it to a minio container.

This is the code:

private Mono<Boolean> saveFileToMinio(FilePart filePart) {
        log.info(String.format("About to save database named %s to minio container...", filePart.filename()));
        var result = DataBufferUtils.join(filePart.content()).map(dataBuffer -> {
                    var bytes = dataBuffer.asByteBuffer().array();
                    //dataBuffer.read(bytes);
                    //DataBufferUtils.release(dataBuffer);
                    return bytes;
                }).map(databaseFileService::write)
                .then(Mono.just(true))
                .onErrorMap(throwable -> {
                    log.error(throwable.getMessage(), throwable);
                    return throwable;
                });
        log.info(String.format("Successfully saved database named %s to minio container...", filePart.filename()));
        return result;
    }

This workflow sometimes forces the OS (debian) to kill the java process because of

insufficient memory for the Java Runtime Environment

The jar is being run like so:
/usr/bin/java -Dsun.misc.URLClassPath.disableJarChecking=true -jar /home/pmgr/pmgr.jar

We use openjdk.

Is there an issue with the above method?

Please see the comments above. Commenting these in does not take any effect though.

Any ideas?

EDIT #1:
The strange thing is, that it works X times before killing the process. If you try it X+1 times, the process will be killed.

EDIT #2:
Maybe this is caused by this: https://bugs.openjdk.org/browse/JDK-8214994

I´ll try to use a different JDK and keep you updated ...


Solution

  • It seems that this is caused by the given OpenJDK Bug in EDIT #2. With OpenJDK 17 the issue disappears. So far all is working as expected.