Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSL4J-00D5ak-PU for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2024 18:00:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rSL4I-00Ev74-Md for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2024 18:00:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSL4I-00Ev6s-D5 for pgsql-hackers@lists.postgresql.org; Tue, 23 Jan 2024 18:00:14 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rSL4B-002zvQ-DK for pgsql-hackers@postgresql.org; Tue, 23 Jan 2024 18:00:13 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2cf1586ddb0so8695271fa.1 for ; Tue, 23 Jan 2024 10:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706032806; x=1706637606; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kDDyRsHnP5B8LaaPoSZIwW+Njb+HkyMU2qtGef+Sfag=; b=ieTd8+E1cjrmnuO+SprxF839sy5OYMLhmmUcgCgqPVneiaxksj2DLptAkaAY43lnAX jpn8inczJpdCKdDmTZPQoVYM26Y3QGeH3vM73jVBIRUox3eulTb3v1pREPEas4iwD+nw 6Ycs6m+g2GobYyiSKngw4BLRBDQHZZyi6poWhA80S5K/s45C18MPSg7sYIX3tHgaMY4/ H1/9B4PTnq0fJRtBX6mxXB5irN7NDhBrQtczxGQcCTHFvO/GtKxlh2ccXD9vl7YmAHHW g6q2r8WDIHAp7Qu/ziTcGytnsXu7oAgc60jYr1d9cYD7qoVAh9S3Z3d+WTmNL0uwMbcL SVpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706032806; x=1706637606; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kDDyRsHnP5B8LaaPoSZIwW+Njb+HkyMU2qtGef+Sfag=; b=Oe6cNumZkVUFhJHALc6WXu3IgRvQoivBxN4ZQok3GBTqQuc/CzFeFocQKfcZ6aTCYA lLRZ42AWnb2eguzAk5UuMcq6/tEmnezcT+FqFOVbptnhSHOoImUPEE492fVTewkeU54A 5TD9oPD8fIn0mDTRooXi4JH8cMzCIy3myTVp2bD6CQZXtURKCsmVqiQfZA2bYC78HJiB ywN24OYGLUIEv8lcl+21xkaLxYQHMB7pX9HKKl/PZt3Ef/VpzV1uEwt1kH0ulWeGAX7j J9H0JSCIanEWMB6M4CwIO2wAE/iWm+JPI3e/khChniX5sJWY6M+BfLSC3lZ6EyCzxqfW Us4A== X-Gm-Message-State: AOJu0YytPtf4bAKcUn8u6kdA8JiBUE/GQwmym47kyF/2LPTitYz5151A pbrU8GVZlkxpuuWO90oJUfqYKDYRt+lqj0Cm8kwbNr9XqccDDabW X-Google-Smtp-Source: AGHT+IEabJStluJtdFZ/8DpGffZ8D9P/hE1sJYKtgjhkD6paqqXw+j5wB0h6YSSg90YDmgDgwKHhbg== X-Received: by 2002:a05:651c:54e:b0:2ce:540:f693 with SMTP id q14-20020a05651c054e00b002ce0540f693mr110817ljp.25.1706032805422; Tue, 23 Jan 2024 10:00:05 -0800 (PST) Received: from [1.0.0.7] ([91.185.77.50]) by smtp.gmail.com with ESMTPSA id x7-20020a2e8387000000b002ce0198f8ecsm1356014ljg.17.2024.01.23.10.00.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jan 2024 10:00:04 -0800 (PST) Message-ID: Date: Tue, 23 Jan 2024 21:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: On login trigger: take three Content-Language: en-US To: Alexander Korotkov , Daniel Gustafsson Cc: Tom Lane , Mikhail Gribkov , Michael Paquier , Robert Haas , Andres Freund , Greg Nancarrow , Ivan Panchenko , Teodor Sigaev , Ibrar Ahmed , vignesh C , Pavel Stehule , PostgreSQL Hackers , Amit Kapila , Masahiko Sawada References: <2133270.1698592561@sss.pgh.pa.us> <44807d19-81a6-3884-3e0f-22dd99aac3ed@gmail.com> From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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