Error when importing backup

Hi,
I just installed a fresh xwiki and I want to import the data from the standalone version we used to test the product.But I’m getting an error after the upload of the .xar (800 Mio)

In /var/log/tomcat9/catalina.out, ther is a message :

[2020-03-30 18:04:43] [info] com.xpn.xwiki.XWikiException: Error number 11008 in 11: Exception while parsing uploaded file

Caused by: java.io.IOException: Aucun espace disponible sur le périphérique
[2020-03-30 18:04:43] [info] #011at java.base/java.io.FileOutputStream.writeBytes(Native Method)
[2020-03-30 18:04:43] [info] #011at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
[2020-03-30 18:04:43] [info] #011at org.apache.commons.io.output.ThresholdingOutputStream.write(ThresholdingOutputStream.java:128)
[2020-03-30 18:04:43] [info] #011at org.apache.commons.fileupload.util.Streams.copy(Streams.java:105)
[2020-03-30 18:04:43] [info] #011at org.apache.commons.fileupload.util.Streams.copy(Streams.java:68)
[2020-03-30 18:04:43] [info] #011at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:346)
[2020-03-30 18:04:43] [info] #011… 48 common frames omitted
[2020-03-30 18:04:43] [info] 2020-03-30 18:04:43,182 [http://lin1e135.tlt:8080/xwiki/bin/upload/XWiki/XWikiPreferences] WARN o.x.c.i.DefaultCSRFToken - CSRFToken: Secret token verification failed, token: “null”, stored token: “YwmzaD6KpNGDE3bFWJ0gSg”

The message is in french “Aucun espace disponible sur le périphérique”
and the translation is : “No space available on the device”

But I dont’t see where there is not enough space

root@lin1e135:~ #df -h
Sys. de fichiers             Taille Utilisé Dispo Uti% Monté sur
udev                           2,0G       0  2,0G   0% /dev
tmpfs                          395M     31M  365M   8% /run
/dev/mapper/debian9--vg-root   6,0G    2,6G  3,1G  46% /
tmpfs                          2,0G    8,0K  2,0G   1% /dev/shm
tmpfs                          5,0M       0  5,0M   0% /run/lock
tmpfs                          2,0G       0  2,0G   0% /sys/fs/cgroup
/dev/mapper/debian9--vg-var     16G    2,2G   13G  15% /var
/dev/sda1                      236M     76M  149M  34% /boot
/dev/mapper/debian9--vg-tmp    461M    2,4M  431M   1% /tmp
/dev/mapper/debian9--vg-home    21G     45M   20G   1% /home
tmpfs                          190M       0  190M   0% /run/user/0
tmpfs                          190M       0  190M   0% /run/user/1003

I thought it was the /tmp but I don’t know how change the path for xwiki

Hi, see https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Configuration/#HConfiguringDirectories

Thank you for this quick answer

Here’s what I got with this code :

{{velocity}}
$services.component.getInstance('org.xwiki.environment.Environment').getPermanentDirectory()
$services.component.getInstance('org.xwiki.environment.Environment').getTemporaryDirectory()
{{/velocity}}

result :

/var/lib/xwiki/data
/var/cache/tomcat9/Catalina/localhost/xwiki/xwiki-temp

#ls -l /var/lib/xwiki
total 4
drwxr-xr-x 7 tomcat tomcat 4096 mars 27 16:05 data

#ls -l /var/cache/tomcat9/Catalina/localhost/xwiki/
total 4
drwxr-x— 6 tomcat tomcat 4096 mars 30 18:13 xwiki-temp

tomcat can write in both folders and /var has 13Gio left.
So what’s wrong ?

The directories you look at, are the directories used by XWiki. Maybe some 3rd party lib we use use another tmp dir. Stack trace says:

Caused by: java.io.IOException: Aucun espace disponible sur le périphérique
[2020-03-30 18:04:43] [info] #011at java.base/java.io.FileOutputStream.writeBytes(Native Method)
[2020-03-30 18:04:43] [info] #011at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
[2020-03-30 18:04:43] [info] #011at org.apache.commons.io.output.ThresholdingOutputStream.write(ThresholdingOutputStream.java:128)
[2020-03-30 18:04:43] [info] #011at org.apache.commons.fileupload.util.Streams.copy(Streams.java:105)

So it seems Commons FileUpload is trying to save some content on the file system somewhere.

From what I see in commons fileupload source code, it uses the “java.io.tmpdir” system property:

    protected File getTempFile() {
        if (tempFile == null) {
            File tempDir = repository;
            if (tempDir == null) {
                tempDir = new File(System.getProperty("java.io.tmpdir"));
            }

            String tempFileName = format("upload_%s_%s.tmp", UID, getUniqueId());

            tempFile = new File(tempDir, tempFileName);
        }
        return tempFile;
    }

in DiskFileItem.java

Try this:

{{velocity}}
$services.component.getInstance('org.xwiki.environment.Environment').getPermanentDirectory()
$services.component.getInstance('org.xwiki.environment.Environment').getTemporaryDirectory()
{{/velocity}}

{{groovy}}
print System.getProperty('java.io.tmpdir')
{{/groovy}}

print System.getProperty('java.io.tmpdir') returns /tmp and it has only 431M left

I tried to add JAVA_OPTS="${JAVA_OPTS} -Djava.io.tmpdir=/var/tmp" in /etc/default/tomcat9 or modify the environment variable with export _JAVA_OPTIONS=-Djava.io.tmpdir=/var/tmp
but nothing seems to work.

FYI, I’ve updated https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Configuration/#HConfiguringDirectories

The leading underscore seems wrong. There are several ways to configure and start Tomcat. I’m afraid you’ll need to check the Tomcat docs. But what you did seems ok.

@tmortagne BTW, is it expected that the upload of a file in xwiki is not using the xwiki tmp dir?

As a matter of fact, it’s not. But it’s useless for xwiki.

I’m going to dig deeper into the Tomcat docs.
Merci pour tout :wink:

Actually it’s a fallback only. Need to find what is the value of repository.

ok found this code:

    public void loadFileList(XWikiContext context) throws XWikiException
    {
        XWiki xwiki = context.getWiki();
        loadFileList(
            xwiki.getSpacePreferenceAsLong(UPLOAD_MAXSIZE_PARAMETER, UPLOAD_DEFAULT_MAXSIZE, context),
            (int) xwiki.getSpacePreferenceAsLong(UPLOAD_SIZETHRESHOLD_PARAMETER, UPLOAD_DEFAULT_SIZETHRESHOLD, context),
            xwiki.Param("xwiki.upload.tempdir"), context);
    }

So the value of xwiki.upload.tempdir seems to be the value for the repository, and if not writable or cannot create the directory, then it’ll fallback to java.io.tmpdir.

EDIT: Confirmed in the comments of Loading...

I’ve created Loading...

So where do I set xwiki.upload.tempdir ?

in xwiki.cfg but best IMO is to make sure that java.io.tmpdir is set and has enough space since there might be other 3rd party libs using it too. But yes you could try setting it as a test.