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

Server LTR: Why QGIS_PREFIX_PATH needs write permissions / ¿is WMS cache written there? #59613

Open
2 tasks done
lorenzogrv opened this issue Nov 27, 2024 · 1 comment
Open
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@lorenzogrv
Copy link

lorenzogrv commented Nov 27, 2024

What is the bug or the crash?

I'm not sure this is a bug. Qgis server tries to cache WMS requests but fails with:

QNetworkDiskCache::prepare() unable to open temporary file

After some research this seems related to the QGIS_PREFIX_PATH env variable. There isn't too much about that variable on docs. Please see:

Our qgis-server is running at a container which has QGIS_PREFIX_PATH=/usr. Perms inside /usr directory are drwxr-xr-x root root. That seems to have sense for me.

The qgis user runs the qgis-server because we don't want our container running its process as root.

It seems qgis user needs write permissions somewhere within /usr. That does not make sense for me.

  • ¿Does WMS cache need to write files with QGIS_PREFIX_PATH?
  • ¿Where does WMS cache need the write perms?

Steps to reproduce the issue

Need feedback to provide an useful reproduction

Versions

$ qgis_mapserver --version
QGIS 3.34.12-Prizren 'Prizren' (exported)
QGIS code branchRelease 3.34
Qt version 5.15.15
Python version 3.12.7
GDAL/OGR version 3.9.3
PROJ version 9.5.0
EPSG Registry database version v11.016 (2024-08-31)
GEOS version 3.13.0-CAPI-1.19.0
SQLite version 3.46.1
OS Debian GNU/Linux trixie/sid

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@lorenzogrv lorenzogrv added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Nov 27, 2024
@kaloyan13
Copy link

kaloyan13 commented Dec 18, 2024

I saw the same QNetworkDiskCache error in my docker image using QGIS Server 3.34.4-Prizren.
After debugging I figured out the following:

  1. QGIS cache dir is properly detected from environment variable
qgis-server_1  | 11:24:55 INFO Server[16]:   - QGIS_SERVER_CACHE_DIRECTORY / '/cache/directory' (Specify the cache directory): '/var/www/cache/qgis' (read from ENVIRONMENT_VARIABLE)
qgis-server_1  | 11:24:55 INFO Server[16]:   - QGIS_SERVER_CACHE_SIZE / '/cache/size' (Specify the cache size): '268435456' (read from DEFAULT_VALUE)
  1. QGIS tries to write to the wrong cache directory.
$ strace -ff -p ${QGIS_PID} -o /tmp/qgis_trace.txt
$ grep -RH 'cache' qgis_trace.txt.*
qgis_trace.txt.125421:openat(AT_FDCWD, "/.cache/QGIS/QGIS3/prepared", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = -1 ENOENT (No such file or directory)
qgis_trace.txt.125421:statx(AT_FDCWD, "/.cache/QGIS/QGIS3/data8/8/1lpxd2j8.d", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7f3b1eb56340) = -1 ENOENT (No such file or directory)
  1. I am using Apache2 proxy_fcgi to send requests to QGIS.
ProxyPass		/cgi-bin/ fcgi://qgis-server:9000/
ProxyPassReverse	/cgi-bin/ fcgi://qgis-server:9000/

Tried setting environment inside Apache config, using SetEnv/ProxyFCGISetEnvIf, but that didn't help.

  1. Workaround for the bug
mkdir -p /.cache/QGIS/
chown -R www-data:www-data /.cache/QGIS/
ln -s /var/www/cache/qgis /.cache/QGIS/QGIS3

wms_request.txt
qgis_server_1.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

No branches or pull requests

2 participants