Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.io.IOException: posix_fallocate() returned 22 on RaspberryPi (Raspbian) #465

Closed
PestusAtSAG opened this issue Jan 3, 2023 · 7 comments

Comments

@PestusAtSAG
Copy link

PestusAtSAG commented Jan 3, 2023

I am running a java application on a RaspberryPi (OS: NAME="Raspbian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)")

Java Version:
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Raspbian-1deb11u1)
OpenJDK Server VM (build 11.0.16+8-post-Raspbian-1deb11u1, mixed mode)

Using chronicle-map version 3.22.9

I got following exception by creating ChronicleMap (Configuration: averageKeySize: 8, averageValueSize: 4194304, maxBloatFactor: 5.0, entries: 10)

java.io.IOException: posix_fallocate() returned 22
at net.openhft.chronicle.hash.impl.util.jna.PosixFallocate.fallocate(PosixFallocate.java:25)
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.fallocate(VanillaChronicleHash.java:1128)
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.map(VanillaChronicleHash.java:1113)
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.createMappedStoreAndSegments(VanillaChronicleHash.java:515)
at net.openhft.chronicle.map.ChronicleMapBuilder.createWithNewFile(ChronicleMapBuilder.java:1843)
at net.openhft.chronicle.map.ChronicleMapBuilder.createWithFile(ChronicleMapBuilder.java:1741)
at net.openhft.chronicle.map.ChronicleMapBuilder.recoverPersistedTo(ChronicleMapBuilder.java:1622)
at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1605)
at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1597)
at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1591)

There is enough space on the volume (51G free), type ext4:
/dev/root ext4 59G 5,0G 51G 9% /

The applications breaks with this exception but the file is correctly generated! When i restart the application, everything is working fine.

Do you have any idea why posix_fallocate() returns error code 22, even the file is generated and valid?

I added also a ChronicleHashCorruption.Listener to .createOrRecoverPersistedTo

this listener writes to log:

Message: file=/home/opcua-thinedge/opcua/data/deviceTypeMapping.dat: size-prefixed blob readiness bit is set to NOT_COMPLETE
Message: segment headers offset of map at /home/opcua-thinedge/opcua/data/deviceTypeMapping.dat corrupted. stored: 0, should be: 4096
Message: data store size of map at /home/opcua-thinedge/opcua/data/deviceTypeMapping.dat corrupted. stored: 0, should be: 43389504

but this is not true, after the application is stopped, the file is exactly created with the expected size!

@JerryShea
Copy link
Contributor

@PestusAtSAG we also see this on our Continuous Integration ARM box. We build and test all Chronicle products on ARM even though it it is not (yet) a supported production platform. The majority of tests pass but a few fail, and this is one of the outstanding issues.
We are busy with customer work and so unlikely to get this in the short term. Any investigation you can do yourself would be very helpful, or if you would like us to prioritise it please review the support offerings at https://chronicle.software/openhft-support/

@PestusAtSAG
Copy link
Author

PestusAtSAG commented Jan 4, 2023

@JerryShea
Ok, i am going to try to put some effort into investigation. I could at least find out what error number 22 means:

EINVAL offset was less than 0, or len was less than or equal to
0, or the underlying filesystem does not support the
operation.

I debugged the PosixFallocate class and the offset is equal 0 (not less than 0) and len is bigger than 0 (not equal or less 0). I suppose the filesystem support the operation as well. I can call in the terminal:

fallocate --posix -o 1024 -l 1024 test.dat

and the operation was working on the filesystem.
I am not sure yet why the the jna method return (errno 22) invalid arguments?

@torsSAG
Copy link

torsSAG commented Jan 5, 2023

https://www.phoronix.com/news/EXT4-No-Delalloc-Perf-Fix maybe delalloc causes the error.

@PestusAtSAG
Copy link
Author

We found a solution, we are running on a 64 bit arm, instead of using:

private static native int posix_fallocate(int fd, long offset, long length);

we are using now

private static native int posix_fallocate64(int fd, long offset, long length);

which is working!

It took me a while to find out, a colleage of my gave me the hint, thanks Elias!

I can create a PR if you like, however, it is not easy to determine which OS bit version is used from JVM. At least i couldn't find it quickly! We will solve it with a config flag and overload the class net.openhft.chronicle.hash.impl.util.jna.PosixFallocate.

@JerryShea
Copy link
Contributor

Thanks for the investigation and comments everyone! Can you try building this version of the Posix library locally to see if it resolves your issue?

@PestusAtSAG
Copy link
Author

PestusAtSAG commented Jan 6, 2023

Yes, I tested your PR successfully. When can we expect a fix for the class net.openhft.chronicle.hash.impl.util.jna.PosixFallocate in the ChronicalMap library? Is there a another bugfix release planned for 3.22.X? We decided not to overload your class and wait instead of a fixed version of Chronical-Map.

@JerryShea
Copy link
Contributor

JerryShea commented Jan 13, 2023

@PestusAtSAG this is now fixed in the develop branch (by #466)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants