luxms / rw_redis_fdw

Other
0 stars 3 forks source link

crash on INSERT when server is built with --enable-cassert #17

Closed petrov9268 closed 1 month ago

petrov9268 commented 1 month ago

INSERTs fail and the server process crashes on PostgreSQL that was built with the --enable-cassert build flag:

psql (16.3, server 15.5)
Type "help" for help.

postgres=# CREATE FOREIGN TABLE assert_error (
  key TEXT,
  value TEXT
) SERVER localredis;

INSERT INTO assert_error VALUES ('test', 'test');
CREATE FOREIGN TABLE
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
!?>

Server logs:

redis_fdw-1  | TRAP: FailedAssertion("param->param != NULL", File: "redis_fdw.c", Line: 959, PID: 13)
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(ExceptionalCondition+0x7b)[0x95fc4b]
redis_fdw-1  | /usr/local/pgsql/lib/redis_fdw.so(+0x5523)[0x7fdbc0969523]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT[0x76ef60]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(create_plan+0x31)[0x771021]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(standard_planner+0x144)[0x77f644]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(pg_plan_query+0x48)[0x845a48]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(pg_plan_queries+0x41)[0x845b41]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT[0x845e43]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(PostgresMain+0x16a6)[0x8479d6]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT[0x7bd672]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(PostmasterMain+0xce5)[0x7be615]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(main+0x1e5)[0x5100f5]
redis_fdw-1  | /lib64/libc.so.6(+0x29590)[0x7fdbc9a6f590]
redis_fdw-1  | /lib64/libc.so.6(__libc_start_main+0x80)[0x7fdbc9a6f640]
redis_fdw-1  | postgres: postgres postgres 172.18.0.1(40292) INSERT(_start+0x25)[0x5103d5]
redis_fdw-1  | 2024-09-12 22:08:38.708 UTC [1] LOG:  server process (PID 13) was terminated by signal 6: Aborted
redis_fdw-1  | 2024-09-12 22:08:38.708 UTC [1] DETAIL:  Failed process was running: INSERT INTO assert_error VALUES ('test', 'test');
redis_fdw-1  | 2024-09-12 22:08:38.708 UTC [1] LOG:  terminating any other active server processes
redis_fdw-1  | 2024-09-12 22:08:38.711 UTC [14] FATAL:  the database system is in recovery mode
redis_fdw-1  | 2024-09-12 22:08:38.711 UTC [1] LOG:  all server processes terminated; reinitializing

It happens here.

The problem is that most of the time this field is actually NULL. Moreover, since the very first commit there has been an error in this line: eabc370

This was later fixed when PostgreSQL 13 support was introduced: 7d32b93

However, even when building on this commit, it still crashes, even on 11.22.

This check seems to be some kind of leftover from the pre-10 versions.