grass
grass copied to clipboard
[Bug] r.patch fails if one input is a GRASS vrt and nprocs > 1
Describe the bug
It seems there is a race condition with parallelised r.patch in G85 if one input is a GRASS vrt consisting of many files, the error is "Invalid descriptor: X" coming from https://github.com/OSGeo/grass/blob/main/lib/raster/close.c#L104. It works with nprocs=1. In a GRASS vrt, the source raster maps are opened and closed on demand in order to avoid issues like in #6615.
To reproduce
- Create a GRASS vrt with
r.buildvrtconsisting of a large number of files - Use a fast CPU with at least 6 cores (not threads but real cores)
- Patch the GRASS vrt with another raster map using the max number of available threads
Solution
For parallelisation, some sort of file open/close lock needs to be implemented in /lib/raster
System description
G85
Additional context
Attempting to patch the results of AI models for semantic segmentation which require small input tiles of typically the size 256x256 pixels to 512x512 pixels.