Implementation of SRTM1HgtFileInfo is not thread safe

Hi,

When running SNAP with parallelisation, problems may occur when loading DEM files. We got these errors in the logs:

May 06, 2020 8:46:57 PM org.esa.snap.core.dataop.dem.ElevationFile getFile
SEVERE: Illegal file name format: N51E003.SRTMGL1.hgt.zip
May 06, 2020 8:46:57 PM org.esa.snap.core.dataop.dem.ElevationFile getFile
SEVERE: Illegal file name format: N51E004.SRTMGL1.hgt.zip
May 06, 2020 8:46:57 PM org.esa.snap.core.dataop.dem.ElevationFile getRemoteHttpFile
INFO: http retrieving http://step.esa.int/auxdata/dem/SRTMGL1/N51E003.SRTMGL1.hgt.zip
May 06, 2020 8:46:57 PM org.esa.snap.core.dataop.dem.ElevationFile getRemoteHttpFile
INFO: http retrieving http://step.esa.int/auxdata/dem/SRTMGL1/N51E004.SRTMGL1.hgt.zip
May 06, 2020 8:46:57 PM org.esa.snap.core.dataop.dem.ElevationFile getRemoteHttpFile
WARNING: http error:/data/MEP/DEM/SRTM 1Sec HGT/N51E003.SRTMGL1.hgt.zip (Permission denied) on http://step.esa.int/auxdata/dem/SRTMGL1/N51E003.SRTMGL1.hgt.zip
May 06, 2020 8:46:57 PM org.esa.snap.core.dataop.dem.ElevationFile getRemoteHttpFile
WARNING: http error:/data/MEP/DEM/SRTM 1Sec HGT/N51E004.SRTMGL1.hgt.zip (Permission denied) on http://step.esa.int/auxdata/dem/SRTMGL1/N51E004.SRTMGL1.hgt.zip
May 06, 2020 9:20:41 PM be.vito.terrascope.snapgpt.ProcessFilesGPT$4 printDoneMessage
INFO: Done Executing processing graph

At first sight, these file names look correct so it is strange we get this error. We have all DEM files stored locally, so there should be no need to retrieve them from the online server while processing. As we don’t want the DEM files to be downloaded again, the processing has no write permission to the local DEM directory. The output image of the processing looks like this as a result. The missing part is also not consistent, which I also mentioned in this thread: Missing data in output when using file tile cache on Spark

I traced back this error to the implementation of the SRTM1HgtFileInfo class in snap-dem. It turns out that the parser in this class is not thread safe, as the parser object is defined as a static member variable of the SRTM1HgtFileInfo class, but the parser itself is stateful. This results in interference when multiple SunTileScheduler threads are trying to load DEM files at the same time.

I will create a pull request on GitHub to fix this issue.

Here is the pull request: https://github.com/senbox-org/snap-engine/pull/230

3 Likes

Many thanks for the pull request. I’ve added a review on GitHub. The review from @lveci is still pending.