-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
vsicurl cache/concurrency issue when using multiple threads #1244
Comments
gdal compilation:
|
I can confirm that I have also run into this bug; the problem (probably a data race) only occurs when I access the files via curl, but not when accessing the files directly, in both cases using a fair number of threads. I am still looking at the source to see if there is a simple way to completely disable the CPL_VSIL_CURL_CACHE. Or has this since been fixed in 2.5.x ? |
@fvdbergh To disable, perhaps you could set CPL_VSIL_CURL_NON_CACHED to |
@pedros007 I tried a number of things, and eventually rummaged around in the source code. Unfortunately one cannot set the cache size to zero (the code then simply resets it to 16 MB). I tried hacking the GDAL 2.4.0 code such that all URLs behave as if they belong to the CPL_VSIL_CURL_NON_CACHED set. I even tried to replace the Null_lock (the default template argument to the cache) with a std::guard_lock with a std::mutex. As a last resort, I tried sprinkling in a bunch std::guard_locks around a global std::mutex I added, but to no avail; my multiple threads kept on clobbering some shared state. Trying to find the actual race condition with valgrind / drd did not work either: there were far too many false positives, so I gave up looking for the problem. Since I had been busy reprojecting a whole bunch of files from the Sentinel 2 AWS S3 bucket (/vsis3 goes through /vsicurl), I could get away with factoring out my calls to the gdalwarp(er) into little stub programs that I ended running in sub-processes. As one would expect, that worked perfectly, even though it is not the most elegant solution. |
@fvdbergh Ahh, you're right gdal/gdal/port/cpl_vsil_curl.cpp Lines 4233 to 4239 in fceb74a
I would expect this to work: CPL_VSIL_CURL_NON_CACHED="/vsis3/"
|
Hi, I was pointed to this issue by @sgillies from After reading this issue I have tried playing around with various CACHE related settings and found that setting I'm not familiar with the codebase, but it seems to be used only here: gdal/gdal/port/cpl_vsil_curl.cpp Lines 2960 to 2963 in 1c79ed7
|
Candidate fix in #2012 |
/vsicurl (and derived filesystems): fix concurrency issue with multithreaded reads (fixes #1244)
Backported to 3.0 and 2.4 branches |
Expected behavior and actual behavior.
Concurrently opening multiple COGs through vsicurl fails intermittently. I suspect the issue is related to a race when accessing the global vsicurl block cache.
Error Messages can vary:
Steps to reproduce the problem.
Here is an "artificial" test case aimed at easily reproducing the issue. Setting CPL_VSIL_CURL_CACHE_SIZE to a large size is a temporary workaround, but the issue does still happen in that case.
0.tif
and put it somewhere accessible to a local webserver. The headers of my test case was roughly 50k:make sure it is accessible from http://localhost/0.tif (and 1.tif, 2.tif, etc...), or update the provided source code to point to the correct locations
compile
Operating system
Ubuntu 18.04 64 bit
Ubuntu 18.10
Alpine
GDAL version and provenance
2.4.0 locally compiled
/cc @Manuscrit
The text was updated successfully, but these errors were encountered: