Re: PATCH: Add REINDEX tag to event triggers

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Ajin Cherian <itsajin(at)gmail(dot)com>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Garrett Thornburg <film42(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: PATCH: Add REINDEX tag to event triggers
Date: 2023-12-04 16:49:12
Message-ID: CACJufxEYKDAzbPchzeDJKTHpHFDNw_--uDrwM5hw-CeLRhspOw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 4, 2023 at 11:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
>
> Hi Michael,
>
> 04.12.2023 04:04, Michael Paquier wrote:
> > Anyway, I've been working on the patch for the last few days, and
> > applied it after tweaking a bit its style, code and comments.
>
> Please look at the assertion failure triggered when REINDEX processed by an event trigger:
> CREATE FUNCTION etf() RETURNS EVENT_TRIGGER AS $$ BEGIN PERFORM 1; END $$ LANGUAGE plpgsql;
> CREATE EVENT TRIGGER et ON ddl_command_end EXECUTE FUNCTION etf();
> CREATE TABLE t (i int);
> REINDEX (CONCURRENTLY) TABLE t;
>
> Core was generated by `postgres: law regression [local] REINDEX '.
> Program terminated with signal SIGABRT, Aborted.
>
> warning: Section `.reg-xstate/338911' in core file too small.
> #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140462399108928) at ./nptl/pthread_kill.c:44
> 44 ./nptl/pthread_kill.c: No such file or directory.
> (gdb) bt
> #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140462399108928) at ./nptl/pthread_kill.c:44
> #1 __pthread_kill_internal (signo=6, threadid=140462399108928) at ./nptl/pthread_kill.c:78
> #2 __GI___pthread_kill (threadid=140462399108928, signo=signo(at)entry=6) at ./nptl/pthread_kill.c:89
> #3 0x00007fbff2c09476 in __GI_raise (sig=sig(at)entry=6) at ../sysdeps/posix/raise.c:26
> #4 0x00007fbff2bef7f3 in __GI_abort () at ./stdlib/abort.c:79
> #5 0x000055d88b8bb8de in ExceptionalCondition (conditionName=0x55d88baac6c0 "portal->portalSnapshot == NULL",
> fileName=0x55d88baac2c4 "pquery.c", lineNumber=1796) at assert.c:66
> #6 0x000055d88b6d6186 in EnsurePortalSnapshotExists () at pquery.c:1796
> #7 0x000055d88b47d21a in _SPI_execute_plan (plan=0x55d88bfd2a80, options=0x7ffdc53b94c0, snapshot=0x0,
> crosscheck_snapshot=0x0, fire_triggers=true) at spi.c:2579
> #8 0x000055d88b479f37 in SPI_execute_plan_with_paramlist (plan=0x55d88bfd2a80, params=0x0, read_only=false, tcount=0)
> at spi.c:749
> #9 0x00007fbfe6de57ed in exec_run_select (estate=0x7ffdc53b97c0, expr=0x55d88bfba7f8, maxtuples=0, portalP=0x0) at
> pl_exec.c:5815
> #10 0x00007fbfe6dddce9 in exec_stmt_perform (estate=0x7ffdc53b97c0, stmt=0x55d88bfba950) at pl_exec.c:2171
> #11 0x00007fbfe6ddd87c in exec_stmts (estate=0x7ffdc53b97c0, stmts=0x55d88bfbad90) at pl_exec.c:2023
> #12 0x00007fbfe6ddd5f8 in exec_stmt_block (estate=0x7ffdc53b97c0, block=0x55d88bfbade0) at pl_exec.c:1942
> #13 0x00007fbfe6ddccff in exec_toplevel_block (estate=0x7ffdc53b97c0, block=0x55d88bfbade0) at pl_exec.c:1633
> #14 0x00007fbfe6ddbb6a in plpgsql_exec_event_trigger (func=0x55d88bf66840, trigdata=0x7ffdc53b9b00) at pl_exec.c:1198
> #15 0x00007fbfe6df74c7 in plpgsql_call_handler (fcinfo=0x7ffdc53b9aa0) at pl_handler.c:272
> #16 0x000055d88b34f592 in EventTriggerInvoke (fn_oid_list=0x55d88beffa40, trigdata=0x7ffdc53b9b00) at event_trigger.c:1087
> #17 0x000055d88b34edea in EventTriggerDDLCommandEnd (parsetree=0x55d88bed6000) at event_trigger.c:803
> #18 0x000055d88b6d9a41 in ProcessUtilitySlow (pstate=0x55d88beff930, pstmt=0x55d88bed60b0, queryString=0x55d88bed54f0
> "REINDEX (CONCURRENTLY) TABLE t;", context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x55d88bed6370,
> qc=0x7ffdc53ba310) at utility.c:1937
> #19 0x000055d88b6d7ae9 in standard_ProcessUtility (pstmt=0x55d88bed60b0, queryString=0x55d88bed54f0 "REINDEX
> (CONCURRENTLY) TABLE t;", readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
> dest=0x55d88bed6370, qc=0x7ffdc53ba310) at utility.c:1074
> #20 0x000055d88b6d69ea in ProcessUtility (pstmt=0x55d88bed60b0, queryString=0x55d88bed54f0 "REINDEX (CONCURRENTLY) TABLE
> t;", readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x55d88bed6370,
> qc=0x7ffdc53ba310) at utility.c:530
> #21 0x000055d88b6d52b8 in PortalRunUtility (portal=0x55d88bf509f0, pstmt=0x55d88bed60b0, isTopLevel=true,
> setHoldSnapshot=false, dest=0x55d88bed6370, qc=0x7ffdc53ba310) at pquery.c:1158
> #22 0x000055d88b6d552f in PortalRunMulti (portal=0x55d88bf509f0, isTopLevel=true, setHoldSnapshot=false,
> dest=0x55d88bed6370, altdest=0x55d88bed6370, qc=0x7ffdc53ba310) at pquery.c:1315
> #23 0x000055d88b6d4979 in PortalRun (portal=0x55d88bf509f0, count=9223372036854775807, isTopLevel=true, run_once=true,
> dest=0x55d88bed6370, altdest=0x55d88bed6370, qc=0x7ffdc53ba310) at pquery.c:791
> #24 0x000055d88b6cd74a in exec_simple_query (query_string=0x55d88bed54f0 "REINDEX (CONCURRENTLY) TABLE t;") at
> postgres.c:1273
> #25 0x000055d88b6d26f6 in PostgresMain (dbname=0x55d88bf0c860 "regression", username=0x55d88bf0c848 "law") at
> postgres.c:4653
> #26 0x000055d88b5f2014 in BackendRun (port=0x55d88bf00f80) at postmaster.c:4425
> #27 0x000055d88b5f1636 in BackendStartup (port=0x55d88bf00f80) at postmaster.c:4104
> #28 0x000055d88b5edcf6 in ServerLoop () at postmaster.c:1772
> #29 0x000055d88b5ed5f3 in PostmasterMain (argc=3, argv=0x55d88becf700) at postmaster.c:1471
> #30 0x000055d88b49d2ca in main (argc=3, argv=0x55d88becf700) at main.c:198
>
> Best regards,
> Alexander

In indexcmd.c, function, ReindexRelationConcurrently
if (indexIds == NIL)
{
PopActiveSnapshot();
return false;
}

So there is no snapshot left, then PERFORM 1; need a snapshot.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2023-12-04 16:50:41 Fwd: Extensible storage manager API - SMGR hook Redux
Previous Message Matthias van de Meent 2023-12-04 16:44:39 Re: Proposal to use JSON for Postgres Parser format