Thread: BUG #18592: rt_raster_to_gdal: Could not load the output GDAL driver after unsuccessful paralell operation

The following bug has been logged on the website:

Bug reference:      18592
Logged by:          Snorri Bergmann
Email address:      snorrib@gmail.com
PostgreSQL version: 16.4
Operating system:   Linux
Description:

We are using 16.4 with PostGIS 3.4.
Recently a DB was migrated from 9.6 to 16.4 using pg_dump.

Occasionally (once a day or every other day) an application stops working.
In the Postgres log the following is repeated:

2024-08-27 08:47:04.787 UTC [3925026] ERROR:  rt_raster_to_gdal: Could not
load the output GDAL driver
2024-08-27 08:47:04.787 UTC [3925026] CONTEXT:  PL/pgSQL function
st_aspng(raster,text[]) line 31 at RETURN
2024-08-27 08:47:04.787 UTC [3925026] STATEMENT:
                    SELECT
                        ST_AsPNG(ST_ColorMap(ST_TRANSFORM(rast, 3857),
...........................

2024-08-27 08:47:04.787 UTC [3924754] ERROR:  rt_raster_to_gdal: Could not
load the output GDAL driver
2024-08-27 08:47:04.787 UTC [3924754] CONTEXT:  PL/pgSQL function
st_aspng(raster,text[]) line 31 at RETURN
etc. etc.

The errors persist until this is executed (which fixes the issue temporarily
at least):
ALTER DATABASE mydb SET postgis.gdal_enabled_drivers TO 'GTiff PNG JPEG';
ALTER SYSTEM SET postgis.gdal_enabled_drivers TO 'ENABLE_ALL';
SELECT pg_reload_conf();

The first  driver error is always preceded by this:
2024-08-27 08:47:04.546 UTC [3925026] WARNING:  cannot set parameters during
a parallel operation
2024-08-27 08:47:04.546 UTC [3925026] CONTEXT:  SQL function "st_transform"
statement 1
2024-08-27 08:47:04.546 UTC [3924754] WARNING:  cannot set parameters during
a parallel operation
2024-08-27 08:47:04.546 UTC [3924754] CONTEXT:  SQL function "st_transform"
statement 1
        parallel worker
And then the driver errors appear repeatedly:
2024-08-27 08:47:04.787 UTC [3925026] ERROR:  rt_raster_to_gdal: Could not
load the output GDAL driver
.
.
.