pglogical icon indicating copy to clipboard operation
pglogical copied to clipboard

Segfault with triggers

Open slardiere opened this issue 5 years ago • 3 comments

Hi,

I use PostgreSQL 11.6 and pglogical 2.2.2 on debian, with deb packages. I'm using two instances in the same system.

As I need to filter DELETE on the subscriber side, I implement a simple plpgsql trigger function, on the subscriber side. The trigger is fired, then, in some case, return null to not apply the delete. At this moment, postgres segfault with this message in the logfile :

LOG:  background worker "pglogical apply 32935:3371347705" (PID 95481) was terminated by signal 11: Segmentation fault

Then postgres restart, and loop over with the same problem. I can reproduce the situation, The stack trace is :

#0  relation_close (relation=0x0, lockmode=lockmode@entry=0) at ./build/../src/backend/access/heap/heapam.c:1272
#1  0x00007fb43f899c25 in pglogical_relation_close (rel=rel@entry=0x55ba97094500, lockmode=lockmode@entry=0) at ./pglogical_relcache.c:200
#2  0x00007fb43f8925a8 in handle_delete (s=s@entry=0x7ffc4fc44610) at ./pglogical_apply.c:698
#3  0x00007fb43f8941f8 in replication_handler (s=0x7ffc4fc44610) at ./pglogical_apply.c:1139
#4  apply_work (streamConn=streamConn@entry=0x55ba97052f00) at ./pglogical_apply.c:1421
#5  0x00007fb43f894cd6 in pglogical_apply_main (main_arg=<optimized out>) at ./pglogical_apply.c:1976
#6  0x000055ba957f044d in StartBackgroundWorker () at ./build/../src/backend/postmaster/bgworker.c:834
#7  0x000055ba957fd258 in do_start_bgworker (rw=0x55ba96feb060) at ./build/../src/backend/postmaster/postmaster.c:5721
#8  maybe_start_bgworkers () at ./build/../src/backend/postmaster/postmaster.c:5947
#9  0x000055ba957fded5 in sigusr1_handler (postgres_signal_arg=<optimized out>) at ./build/../src/backend/postmaster/postmaster.c:5094
#10 <signal handler called>
#11 0x00007fb44562f5e3 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:84
#12 0x000055ba955806e4 in ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1671
#13 0x000055ba957ff081 in PostmasterMain (argc=5, argv=0x55ba96f99e40) at ./build/../src/backend/postmaster/postmaster.c:1380
#14 0x000055ba95582624 in main (argc=5, argv=0x55ba96f99e40) at ./build/../src/backend/main/main.c:228

Attached script can reproduce the problem

Regards,

replilogique04.sql.gz

slardiere avatar Dec 03 '19 09:12 slardiere

Has anyone looked into this for you yet?

luss avatar Feb 18 '20 17:02 luss

I don't think so, no ; actually, I don't need it, because trigger was not the solution, but it's still a bug, afaik.

slardiere avatar Mar 16 '20 14:03 slardiere

#303 fixes this

jcasanov avatar Feb 24 '21 16:02 jcasanov