0

We are using Ubuntu server and Java 8 with Spring Boot 1.4.2 release with Docker deployment in Ubuntu. In a folder /home/tempAttachment there are 100 millions of directories and the code:

public synchronized static File getFile(String filePath) throws IOException
{
    java.nio.file.Path files12 = null;
    File tempFile= new File(filePath);
    if(!tempFile.getParentFile().exists())
    {
        files12 = java.nio.file.Files.createDirectories(java.nio.file.Paths.get(tempFile.getParentFile().getAbsolutePath()));
        tempFile=  files12.toFile();
    }
    
    return tempFile;
}

Gives an error below:

java.nio.file.FileSystemException: /home/TempAttachment/email/plain-2f298db6-6ce0-471a-869d-7cb18fd5f351: No space left on device
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)

We are trying to reproduce this error in production in our local laptop, but not able to reproduce. Please help

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
chiku
  • 485
  • 2
  • 8
  • 23
  • 3
    Since you included the only relevant information buried in your stack trace perhaps you haven't noticed the *message* "No space left on device"; not sure why you think you have infinite storage, you do not. – Elliott Frisch Dec 03 '22 at 12:42
  • @ElliottFrisch that is the error message "No space left on device" which is displayed when there are 32% still unused inodes in 2TB storage, thanks for your response – chiku Dec 03 '22 at 12:51
  • 2
    What filesystem do you use? There are restrictions on the number of files: https://stackoverflow.com/questions/466521/how-many-files-can-i-put-in-a-directory – Krzysztof Cichocki Dec 03 '22 at 12:52
  • 2
    Can you create a directory outside of Java, using Bash? My guess is that the filesystem ran out of inodes and therefore reports no space left. – Christoph Dahlen Dec 03 '22 at 13:58
  • @ChristophDahlen its not able to create with java.nio.file.Files.createDirectories in multi-threaded fashion, but its able to create with java.io.File.mkdirs() , sometime it also fails in multi-thread fashion, that's why we have opted for java.nio.file.Files.createDirectories its giving no space error, please help – chiku Dec 03 '22 at 14:22

0 Answers0