Thread: BUG #15288: Logical Replication failed when inserting record whichhas CHECK constraint
BUG #15288: Logical Replication failed when inserting record whichhas CHECK constraint
From
PG Bug reporting form
Date:
The following bug has been logged on the website: Bug reference: 15288 Logged by: Minh Quan TRAN Email address: account@itscaro.me PostgreSQL version: 10.4 Operating system: Linux 64 Description: Hello, I encountered segfault when using logical replication with a check constraint. I looked into /backend/replication/logical/worker.c and found out that - in apply_handle_insert, slot_store_cstrings is called before PushActiveSnapshot - in apply_handle_update & apply_handle_delete, slot_store_cstrings is called after PushActiveSnapshot /* Process and store remote tuple in the slot */ oldctx = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate)); slot_store_cstrings(remoteslot, rel, newtup.values); slot_fill_defaults(rel, estate, remoteslot); MemoryContextSwitchTo(oldctx); PushActiveSnapshot(GetTransactionSnapshot()); Core dump Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `postgres: bgworker: logical replication worker for subscription'. Program terminated with signal SIGSEGV, Segmentation fault. #0 GetActiveSnapshot () at ./build/../src/backend/utils/time/snapmgr.c:843 843 ./build/../src/backend/utils/time/snapmgr.c: No such file or directory. #1 0x000056239fc83ecd in postquel_start (fcache=0x5623a1c83b78, es=0x5623a1c91a70) at ./build/../src/backend/executor/functions.c:809 809 ./build/../src/backend/executor/functions.c: No such file or directory. #2 fmgr_sql (fcinfo=0x5623a1c7af98) at ./build/../src/backend/executor/functions.c:1150 1150 in ./build/../src/backend/executor/functions.c #3 0x000056239fc75b4f in ExecInterpExpr (state=0x5623a1c7aeb8, econtext=0x5623a1c7b898, isnull=<optimized out>) at ./build/../src/backend/executor/execExprInterp.c:672 672 ./build/../src/backend/executor/execExprInterp.c: No such file or directory. #4 0x000056239fc72a96 in ExecEvalExprSwitchContext (isNull=0x7ffdc20d1487 "", econtext=0x5623a1c7b898, state=<optimized out>) at ./build/../src/include/executor/executor.h:308 308 ./build/../src/include/executor/executor.h: No such file or directory. #5 ExecCheck (state=<optimized out>, econtext=econtext(at)entry=0x5623a1c7b898) at ./build/../src/backend/executor/execExpr.c:556 556 ./build/../src/backend/executor/execExpr.c: No such file or directory. #6 0x000056239fdefec0 in domain_check_input (value=value(at)entry=94711038065448, isnull=0 '\000', my_extra=my_extra(at)entry=0x5623a1c79bd0) at ./build/../src/backend/utils/adt/domains.c:180 180 ./build/../src/backend/utils/adt/domains.c: No such file or directory. #7 0x000056239fdf0100 in domain_in (fcinfo=0x7ffdc20d1530) at ./build/../src/backend/utils/adt/domains.c:255 255 in ./build/../src/backend/utils/adt/domains.c #8 0x000056239feccd85 in InputFunctionCall (flinfo=flinfo(at)entry=0x7ffdc20d1900, str=str(at)entry=0x5623a1bf4698 "{test.Type.blabla}", typioparam=typioparam(at)entry=28498, typmod=typmod(at)entry=-1) at ./build/../src/backend/utils/fmgr/fmgr.c:1640 1640 ./build/../src/backend/utils/fmgr/fmgr.c: No such file or directory. #9 0x000056239fecd01d in OidInputFunctionCall (functionId=<optimized out>, str=0x5623a1bf4698 "{test.Type.blabla}", typioparam=28498, typmod=-1) at ./build/../src/backend/utils/fmgr/fmgr.c:1743 1743 in ./build/../src/backend/utils/fmgr/fmgr.c #10 0x000056239fd6429f in slot_store_cstrings (slot=slot(at)entry=0x5623a1c664e8, rel=rel(at)entry=0x5623a1c60bf0, values=values(at)entry=0x7ffdc20d1a70) at ./build/../src/backend/replication/logical/worker.c:354 354 ./build/../src/backend/replication/logical/worker.c: No such file or directory. #11 0x000056239fd64cc2 in apply_handle_insert (s=s(at)entry=0x7ffdc20d5580) at ./build/../src/backend/replication/logical/worker.c:612 612 in ./build/../src/backend/replication/logical/worker.c #12 0x000056239fd65e5b in apply_dispatch (s=0x7ffdc20d5580) at ./build/../src/backend/replication/logical/worker.c:912 912 in ./build/../src/backend/replication/logical/worker.c #13 LogicalRepApplyLoop (last_received=97628639619392) at ./build/../src/backend/replication/logical/worker.c:1119 1119 in ./build/../src/backend/replication/logical/worker.c #14 ApplyWorkerMain (main_arg=<optimized out>) at ./build/../src/backend/replication/logical/worker.c:1671 1671 in ./build/../src/backend/replication/logical/worker.c #15 0x000056239fd3540c in StartBackgroundWorker () at ./build/../src/backend/postmaster/bgworker.c:835 835 ./build/../src/backend/postmaster/bgworker.c: No such file or directory. #16 0x000056239fd42175 in do_start_bgworker (rw=0x5623a1b71870) at ./build/../src/backend/postmaster/postmaster.c:5728 5728 ./build/../src/backend/postmaster/postmaster.c: No such file or directory. #17 maybe_start_bgworkers () at ./build/../src/backend/postmaster/postmaster.c:5941 5941 in ./build/../src/backend/postmaster/postmaster.c #18 0x000056239fd42d35 in sigusr1_handler (postgres_signal_arg=<optimized out>) at ./build/../src/backend/postmaster/postmaster.c:5121 5121 in ./build/../src/backend/postmaster/postmaster.c #19 <signal handler called> #20 0x00007f533261a3a3 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:84 84 ../sysdeps/unix/syscall-template.S: No such file or directory. #21 0x000056239fae8c71 in ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1719 1719 ./build/../src/backend/postmaster/postmaster.c: No such file or directory. #22 0x000056239fd4407a in PostmasterMain (argc=3, argv=0x5623a1b49ef0) at ./build/../src/backend/postmaster/postmaster.c:1363 1363 in ./build/../src/backend/postmaster/postmaster.c #23 0x000056239faeac74 in main (argc=3, argv=0x5623a1b49ef0) at ./build/../src/backend/main/main.c:228 228 ./build/../src/backend/main/main.c: No such file or directory. Related discussion in pgsql-hackers https://www.postgresql.org/message-id/flat/4EB4BD78-BFC3-4D04-B8DA-D53DF7160354%40webedia-group.com