pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Mikhail Gribkov <youzhick@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Greg Nancarrow <gregn4422@gmail.com>
Cc: Ivan Panchenko <wao@mail.ru>
Cc: Teodor Sigaev <teodor@sigaev.ru>
Cc: Ibrar Ahmed <ibrar.ahmad@gmail.com>
Cc: vignesh C <vignesh21@gmail.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Subject: Re: On login trigger: take three
Date: Tue, 23 Jan 2024 21:00:01 +0300
Message-ID: <e2a0248e-5f32-af0c-9832-a90d303c2c61@gmail.com> (raw)
In-Reply-To: <CAPpHfdve2Z7e+MsHNk=ddYk-AUwjs7=v9fyMdoRV=Ooysfqo5g@mail.gmail.com>
References: <CAPpHfduF9LHW5PK4si=gpRUnWrwi0J_aNC6rh4BkSgqkz5MYZA@mail.gmail.com>
	<CA+TgmoZWtP2Pr8PurLV2zH+a_WM6cUcXAwBcWpS9Vw5QUfbnPQ@mail.gmail.com>
	<CAPpHfdtOd2eiyE_wN2rfWconeH0BR3gk2n_uQWf6RQvBDvpPBg@mail.gmail.com>
	<CAPpHfdudXAO7QMFcgHJ_wjUt_NqkpOGC+_OhdUJnBfWf+7w_Bg@mail.gmail.com>
	<CAPpHfdvrOcmCXCYtpDG36=idH8RdhUWukXbvt_4DOTMessJQeQ@mail.gmail.com>
	<ZSyLN2HTz_iLSKkH@paquier.xyz>
	<CAPpHfdsbD9sxJFwhSnbcgvii0=gT+7j3XPumNDHZW=mHmVoxOg@mail.gmail.com>
	<CAMEv5_s=s2ZATDf3Zo11naH+25OKuoLyOxtPO+bKPB=qdMd4HQ@mail.gmail.com>
	<CAPpHfdsnBxnh4OWOSe1MyhZN8wZ8Z3CWLPmyc_zg=_MtWmwrFA@mail.gmail.com>
	<CAMEv5_unWRSqnznbRrGaCd00ZYkX9DxYLh1RqX7C1uxumtOedA@mail.gmail.com>
	<2133270.1698592561@sss.pgh.pa.us>
	<CAPpHfds1WuQOiqafsFjH8o_D1jVKjgH2im+VJb-NXtARvxUBqw@mail.gmail.com>
	<44807d19-81a6-3884-3e0f-22dd99aac3ed@gmail.com>
	<B5CD06A6-98AA-4839-8FD1-2EE132CFA76F@yesql.se>
	<CAPpHfdve2Z7e+MsHNk=ddYk-AUwjs7=v9fyMdoRV=Ooysfqo5g@mail.gmail.com>

Hello Alexander and Daniel,

Please look at the following query, which triggers an assertion failure on
updating the field dathasloginevt for an entry in pg_database:
SELECT format('CREATE DATABASE db1 LOCALE_PROVIDER icu ICU_LOCALE en ENCODING utf8
ICU_RULES ''' || repeat(' ', 200000) || ''' TEMPLATE template0;')
\gexec
\c db1 -

CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
BEGIN
   RAISE NOTICE 'You are welcome!';
END;
$$ LANGUAGE plpgsql;

CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
DROP EVENT TRIGGER on_login_trigger;

\c

\connect: connection to server on socket "/tmp/.s.PGSQL.5432" failed: server closed the connection unexpectedly

The stack trace of the assertion failure is:
...
#5  0x000055c8699b9b8d in ExceptionalCondition (
     conditionName=conditionName@entry=0x55c869a1f7c0 "HaveRegisteredOrActiveSnapshot()",
     fileName=fileName@entry=0x55c869a1f4c6 "toast_internals.c", lineNumber=lineNumber@entry=669) at assert.c:66
#6  0x000055c86945df0a in init_toast_snapshot (...) at toast_internals.c:669
#7  0x000055c86945dfbe in toast_delete_datum (...) at toast_internals.c:429
#8  0x000055c8694fd1da in toast_tuple_cleanup (...) at toast_helper.c:309
#9  0x000055c8694b55a1 in heap_toast_insert_or_update (...) at heaptoast.c:333
#10 0x000055c8694a8c6c in heap_update (... at heapam.c:3604
#11 0x000055c8694a96cb in simple_heap_update (...) at heapam.c:4062
#12 0x000055c869555b7b in CatalogTupleUpdate (...) at indexing.c:322
#13 0x000055c8695f0725 in EventTriggerOnLogin () at event_trigger.c:957
...

Funnily enough, when Tom Lane was wondering, whether pg_database's toast
table could pose a risk [1], I came to the conclusion that it's impossible,
but that was before the login triggers introduction...

[1] https://www.postgresql.org/message-id/1284094.1695479962%40sss.pgh.pa.us

Best regards,
Alexander





view thread (171+ messages)  latest in thread

Message-ID: <e2a0248e-5f32-af0c-9832-a90d303c2c61@gmail.com>
Permalink:  ../e2a0248e-5f32-af0c-9832-a90d303c2c61@gmail.com/
Also on:    postgresql.org/message-id/e2a0248e-5f32-af0c-9832-a90d303c2c61@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: exclusion@gmail.com, aekorotkov@gmail.com, daniel@yesql.se, tgl@sss.pgh.pa.us, youzhick@gmail.com, michael@paquier.xyz, robertmhaas@gmail.com, andres@anarazel.de, gregn4422@gmail.com, wao@mail.ru, teodor@sigaev.ru, ibrar.ahmad@gmail.com, vignesh21@gmail.com, pavel.stehule@gmail.com, amit.kapila16@gmail.com, sawada.mshk@gmail.com
  Subject: Re: On login trigger: take three
  In-Reply-To: <e2a0248e-5f32-af0c-9832-a90d303c2c61@gmail.com>
  References: <CAPpHfduF9LHW5PK4si=gpRUnWrwi0J_aNC6rh4BkSgqkz5MYZA@mail.gmail.com> <CA+TgmoZWtP2Pr8PurLV2zH+a_WM6cUcXAwBcWpS9Vw5QUfbnPQ@mail.gmail.com> <CAPpHfdtOd2eiyE_wN2rfWconeH0BR3gk2n_uQWf6RQvBDvpPBg@mail.gmail.com> <CAPpHfdudXAO7QMFcgHJ_wjUt_NqkpOGC+_OhdUJnBfWf+7w_Bg@mail.gmail.com> <CAPpHfdvrOcmCXCYtpDG36=idH8RdhUWukXbvt_4DOTMessJQeQ@mail.gmail.com> <ZSyLN2HTz_iLSKkH@paquier.xyz> <CAPpHfdsbD9sxJFwhSnbcgvii0=gT+7j3XPumNDHZW=mHmVoxOg@mail.gmail.com> <CAMEv5_s=s2ZATDf3Zo11naH+25OKuoLyOxtPO+bKPB=qdMd4HQ@mail.gmail.com> <CAPpHfdsnBxnh4OWOSe1MyhZN8wZ8Z3CWLPmyc_zg=_MtWmwrFA@mail.gmail.com> <CAMEv5_unWRSqnznbRrGaCd00ZYkX9DxYLh1RqX7C1uxumtOedA@mail.gmail.com> <2133270.1698592561@sss.pgh.pa.us> <CAPpHfds1WuQOiqafsFjH8o_D1jVKjgH2im+VJb-NXtARvxUBqw@mail.gmail.com> <44807d19-81a6-3884-3e0f-22dd99aac3ed@gmail.com> <B5CD06A6-98AA-4839-8FD1-2EE132CFA76F@yesql.se> <CAPpHfdve2Z7e+MsHNk=ddYk-AUwjs7=v9fyMdoRV=Ooysfqo5g@mail.gmail.com> <e2a0248e-5f32-af0c-9832-a90d303c2c61@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox