Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfPcG-0003SI-PI for pgsql-general@arkaria.postgresql.org; Sun, 31 May 2020 15:11:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jfPcF-0007bQ-HP for pgsql-general@arkaria.postgresql.org; Sun, 31 May 2020 15:11:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfPcD-0007Yu-RZ for pgsql-general@lists.postgresql.org; Sun, 31 May 2020 15:11:11 +0000 Received: from [66.111.4.29] (helo=out5-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfPc9-0000Zv-U1 for pgsql-general@lists.postgresql.org; Sun, 31 May 2020 15:11:08 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 06EB65C0066; Sun, 31 May 2020 11:10:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 31 May 2020 11:10:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=/ +ZRoz13K/Ak8EQp7Sg0AlqC13gfB6o0QqF/4JABc+4=; b=URLC/dH+q9jI0HCKW cuXIOEiS1jsoWDANdjghYVePHDXX61XgQzUH4AACyHnrmwBUJRArEnAlGNcifM0D XMJjo+u4A3tMBn612gUBrOXySoMQjZnuaf84zOOFioGbnpTYHD0WuFPHifA3YmJY DadaEyexz48yBUQpkvqrvaHw5S+5bqurOOOQ6BrtnyN8RBBjelAzjT1VRDoi06h2 ReIBnaUXnwNAuYgQuTvAn0Z0e4parv26Jorxdjrewa2i/NWi8KHjfHXb87Z6gZQs gMO94T1IvujjGhiM+AezryQrek0BOs0VNvxKNZDaCPyrxZyDcy3E2jSHckut2wMa YMbWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=/+ZRoz13K/Ak8EQp7Sg0AlqC13gfB6o0QqF/4JABc +4=; b=wwpSDRPvEeG7ZoVO4uUKmxEqAnxdn9KL1qyN+M9QGspIIUNJOE+7elKTF IWEaYucdBnRPZ7qDosk5ZdSj1ARTLgupxft+VLw/X5jT0xcA4bEE664bdxQmYUXG HIiFUVsQztyJpkAYtihJXHvkzw57pqKC9lYB9eTRBMABTVHxTHhzqRfzVYc35kF6 USOv8/uvy5WjIH/cscn6oTSh3JQX09+mSVaYWIs3OpOU/Zsh5TICk6T4ta/0e+8B 26j4e8OIJvqsxJTDbfugWAZM2sDS1xe/HX5GG5M+NTbRAWsZHDT4eyRQxgvs5oNA D5fHrlx4Nk/+jE/MuomDw+wDVSh4Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeffedgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepuefgffelff eifeehkefglefhudeutdejvdeujeeufeeftdeghefgffeujefhffeinecuffhomhgrihhn pehpohhsthhgrhgvshhqlhdrohhrghdpphhgrggumhhinhdrohhrghenucfkphepjeehrd dujedvrdehrddvfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 11C5C3061856; Sun, 31 May 2020 11:10:53 -0400 (EDT) Subject: Re: Trigger not firing To: Hans , pgsql-general@lists.postgresql.org References: <159077982292.12069.16282824319899836435@malur.postgresql.org> <0f0451cc-aa72-2cfc-111a-5e956ca16457@xs4all.nl> From: Adrian Klaver Message-ID: Date: Sun, 31 May 2020 08:10:53 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <0f0451cc-aa72-2cfc-111a-5e956ca16457@xs4all.nl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.29 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/31/20 6:19 AM, Hans wrote: > Hi, > > > I've had a weird problem in a production system. The customer had > installed a new server with our software on it. The software installs a > Postgres database schema that includes a number of triggers. The > triggers perform inserts into an additional table. How is the install done? More questions/comments below. > > In this installation, from what I can tell, some triggers somehow got > into a disabled state: > > - they were confirmed to be present (checked using pgAdmin 4). > > - In the trigger property window of pgAdmin 4, the triggers were listed > as enabled. When in doubt use psql to look at the table. So: \d table_name. That will show you the state of the triggers. > > - However, attempts to trigger them (by performing an appropriate insert > or update) didn't visibly result in the trigger running (no entries in > the additional table were created). The insert/update itself worked fine. > > I asked the customer to look in pg_trigger. The triggers were listed > with tgenabled set to 'O' (but I'm not sure if that is the right thing > to look at). That is related to replication: https://www.postgresql.org/docs/12/catalog-pg-trigger.html "Controls in which session_replication_role modes the trigger fires. O = trigger fires in “origin” and “local” modes, D = trigger is disabled, R = trigger fires in “replica” mode, A = trigger fires always. " https://www.postgresql.org/docs/12/runtime-config-client.html#GUC-SESSION-REPLICATION-ROLE "session_replication_role (enum) Controls firing of replication-related triggers and rules for the current session. Setting this variable requires superuser privilege and results in discarding any previously cached query plans. Possible values are origin (the default), replica and local. ... " > > Our software contains no code for disabling triggers. It creates them > once, during database initialisation (i.e. before any data is put in), > and then leaves them alone. I have no reason to believe the customer > messed with the database either. Exactly how is that done? > > How we resolved this: after using "triggers -> enable all" in pgAdmin on > that table, the triggers were now found to be working as expected. So > the trigger code is correct and works, but it (somehow) wasn't enabled. > Moreover, pgAdmin apparently reported this state incorrectly. My > question is: what could have happened? > > Postgres 10.3, 64-bits, Ubuntu (I think 18.04). > > - Are triggers always automatically created in the 'enabled' state, or > are there conditions that could cause them to start as 'disabled', or in > some other way inactive? In the normal dump/restore cycle they set to the state they where in teh source database. > > - What could have caused pgAdmin to report the trigger as 'enabled' even > though, from what I can tell, it really wasn't? That is question for the pgAdmin folks: https://www.pgadmin.org/support/list/ > > - Is there a log file that could shed more light on this situation? The Postgres log file. Should be in: /var/log/postgresql/ > > The customer is willing to try another installation, to see if the > problem can be replicated. I can ask for additional logging to be > enabled if that helps in understanding this problem. What would be > helpful in troubleshooting this? > > > Thanks in advance for any insight you may have, > > Hans > > > > > -- Adrian Klaver adrian.klaver@aklaver.com