#5332 closed enhancement (fixed)

Override proj_log_func to stop proj errors leaking out to PgSQL logs

Reported by: pramsey Owned by: pramsey
Priority: medium Milestone: PostGIS 3.3.3
Component: postgis Version: 3.3.x
Keywords: Cc:

Description

A few proj errors seem to be leaking out. For example, proj_create: crs not found leaks out when the following SQL is run:

select st_transform(st_setsrid(st_makepoint(-12098752.829179065,5130874.004299059),900913),4236)

Seems to be pretty longstanding. proj_log_func is available from 5.1+.

Change History (8)

comment:1 by pramsey, 22 months ago

Milestone: PostGIS 3.3.3PostGIS 3.4.0
Type: defectenhancement

comment:2 by Paul Ramsey <pramsey@…>, 21 months ago

In 404b11d/git:

When libproj throws at error, don't just write the
message to stderr. Catch it and put it into the
PgSQL log at a DEBUG level.
We check all return values and return codes when
calling into the proj API, so the extra error messages
don't really help us.
This is in response to our calls to proj_create()
dumping messages into stderr, which confuses operators.
Our projection code has to try a bunch of possible
strings to instantiate projection objects, some of
which fail (generating a message) and then we fall
back to the next string. The proj "errors" are not
errors from our pov, so we catch them and send them
along at much lower priority.
References #5332

comment:3 by Paul Ramsey <pramsey@…>, 21 months ago

In 09b8c22/git:

When libproj throws at error, don't just write the
message to stderr. Catch it and put it into the
PgSQL log at a DEBUG level.
We check all return values and return codes when
calling into the proj API, so the extra error messages
don't really help us.
This is in response to our calls to proj_create()
dumping messages into stderr, which confuses operators.
Our projection code has to try a bunch of possible
strings to instantiate projection objects, some of
which fail (generating a message) and then we fall
back to the next string. The proj "errors" are not
errors from our pov, so we catch them and send them
along at much lower priority.
References #5332

comment:4 by robe, 21 months ago

Milestone: PostGIS 3.4.0PostGIS 3.3.3

This broke stable 3.3, so reopening https://github.com/postgis/postgis/actions/runs/4181273355/jobs/7243056415

I guess maybe the syntax is different for PROJ 5.2? Cause it should have worked but didn't on this 5.2 ci.

In file included from postgis_module.c:67:
/usr/local/include/proj.h:123:2: error: #error proj.h must be included before proj_api.h
  123 | #error proj.h must be included before proj_api.h
      |  ^~~~~
/usr/local/include/proj.h:167:25: error: conflicting types for 'PJ'
  167 | typedef struct PJconsts PJ;         /* the PJ object herself */
      |                         ^~
In file included from ../libpgcommon/lwgeom_pg.h:27,
                 from postgis_module.c:36:
../liblwgeom/liblwgeom.h:48:3: note: previous declaration of 'PJ' was here
   48 | } PJ;
      |   ^~
In file included from ../liblwgeom/liblwgeom.h:43,
                 from ../libpgcommon/lwgeom_pg.h:27,
                 from postgis_module.c:36:
/usr/local/include/proj.h:272:5: error: expected identifier before numeric constant
  272 |     PJ_LOG_NONE  = 0,
      |     ^~~~~~~~~~~
cc1: note: unrecognized command-line option '-Wno-unknown-warning-option' may have been intended to silence earlier diagnostics
make[1]: *** [<builtin>: postgis_module.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [GNUmakefile:24: all] Error 1
make[1]: Leaving directory '/src/postgis/postgis'
[logbt] saw 'make' exit with code:2 (INT)
Error: Process completed with exit code 2.

comment:5 by pramsey, 21 months ago

Maybe we just bump the version guard forward to 6 then. It's not a critical backpatch.

comment:6 by Paul Ramsey <pramsey@…>, 21 months ago

In 7ee8dda4/git:

Move version for log wrapping errors up to 6, references #5332

comment:7 by Paul Ramsey <pramsey@…>, 21 months ago

In d53dea68/git:

Move version for log wrapping errors up to 6, references #5332

comment:8 by pramsey, 21 months ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.