zohocatalystcatalystserverless

Getting No space left on device error from my Catalyst function


I have a Zoho Catalyst Advanced I/O function where I store the file I get from my API request in my function folder to upload the file to Filestore which has been working fine until recently where I get this below error after I deployed my function to development environment.

Exceptionorg.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. No space left on device
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:350)
    at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:113)
    at FileUpload.runner(FileUpload.java:122)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at com.cop.main.server.AdvancedIOFlavour.invokeMethod(AdvancedIOFlavour.java:30)
    at com.cop.main.server.FunctionFlavourHandler.executeFunction(FunctionFlavourHandler.java:96)
    at com.cop.main.server.ServletHandler.handleFunction(ServletHandler.java:226)
    at com.cop.main.server.ServletHandler.doPost(ServletHandler.java:90)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:665)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
    at com.cop.main.server.ThreadLocalFilter.doFilter(ThreadLocalFilter.java:43)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
    at org.eclipse.jetty.server.Server.handle(Server.java:539)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: No space left on device
    at java.base/sun.nio.ch.FileDispatcherImpl.write0(Native Method)
    at java.base/sun.nio.ch.FileDispatcherImpl.write(Unknown Source)
    at java.base/sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
    at java.base/sun.nio.ch.IOUtil.write(Unknown Source)
    at java.base/sun.nio.ch.IOUtil.write(Unknown Source)
    at java.base/sun.nio.ch.FileChannelImpl.write(Unknown Source)
    at java.base/java.nio.channels.Channels.writeFullyImpl(Unknown Source)
    at java.base/java.nio.channels.Channels.writeFully(Unknown Source)
    at java.base/java.nio.channels.Channels$1.write(Unknown Source)
    at org.apache.commons.io.output.AbstractByteArrayOutputStream.writeToImpl(AbstractByteArrayOutputStream.java:269)
    at org.apache.commons.io.output.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:96)
    at org.apache.commons.io.output.DeferredFileOutputStream.thresholdReached(DeferredFileOutputStream.java:243)
    at org.apache.commons.io.output.ThresholdingOutputStream.checkThreshold(ThresholdingOutputStream.java:105)
    at org.apache.commons.io.output.ThresholdingOutputStream.write(ThresholdingOutputStream.java:231)
    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:105)
    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:68)
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:346)
    ... 33 more

Solution

  • The error indicates you have exhausted the space left for your function folder. You won't be able to access the folder directly from the Catalyst Console. Instead we would suggest you delete those files from your function code. You can use the below sample code snippet to delete the file from the OS temp directory

    private void deleteTempFiles() {
            try {
                // Get the system temp directory path
                Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));
                
                // Traverse the temp directory and delete files
                Files.walkFileTree(tempDir, new SimpleFileVisitor<Path>() {
                    
                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        try {
                            Files.delete(file); // Attempt to delete the file
                            System.out.println("Deleted: " + file);
                        } catch (IOException e) {
                            System.err.println("Failed to delete: " + file + " - " + e.getMessage());
                        }
                        return FileVisitResult.CONTINUE; // Continue traversal
                    }
                    
                    @Override
                    public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                        try {
                            Files.delete(dir); // Attempt to delete the directory
                            System.out.println("Deleted directory: " + dir);
                        } catch (IOException e) {
                            System.err.println("Failed to delete directory: " + dir + " - " + e.getMessage());
                        }
                        return FileVisitResult.CONTINUE; // Continue traversal
                    }
                });
            } catch (IOException e) {
                System.err.println("Error accessing temp directory: " + e.getMessage());
            }
        }