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 1nhtDN-0006CE-8w for pgsql-general@arkaria.postgresql.org; Fri, 22 Apr 2022 13:20:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nhtDL-0005Ok-W4 for pgsql-general@arkaria.postgresql.org; Fri, 22 Apr 2022 13:20:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhtDL-0005JO-Hf for pgsql-general@lists.postgresql.org; Fri, 22 Apr 2022 13:20:47 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nhtDI-0000EQ-BN for pgsql-general@lists.postgresql.org; Fri, 22 Apr 2022 13:20:46 +0000 Received: by mail-wm1-x32d.google.com with SMTP id p189so5084482wmp.3 for ; Fri, 22 Apr 2022 06:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=OXvEsV8kL9y/SyvWL9mx4ftS1CNV+iZYfIGJDZNDHvU=; b=jsnof4fGOS/g3mHyrngKOhFkljHW8AJ8p1FxjeehkIXqODsT2j46ub13qI59eeMgbR aEa8ghtSw4eBuVExxwv5cz3bVu4BOfvHXj8GZSjDL5z9qgEncg354vKWtlfwdp/I9nni lz87KOXUFiCys0HcOmDJmLLi+R/m3VCFTTMB/rAt/ssCdDflvPK3Qnc4Y1Db0R81n+cM ad4P2YY21UX5jT6Bhj/3EY93jgyzMr+/PjMrDD1khdQO2EbbWeYLxRyYbi7y1P1AoMtO j6b+jUaLki1/9KAWC1AS2NUrP/0Cph1xkEB5RYRchOfGKrB+/rWF2FzcV3yvPCLXF7VJ g/IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=OXvEsV8kL9y/SyvWL9mx4ftS1CNV+iZYfIGJDZNDHvU=; b=BJVc0GPecz5KmgqSAMTwpcMMxb4AP0assA1WZZBHlIioxdq2oyfUhF15D3I1Q9vdGQ 7HV3HLrpWxdMDTl7LNPFJ7UEV1jtIKAgxyYv5z7EiM4XOdh2rYTeQJr9VzLtc2SLk6yL PRkFSubthtODTPkFoKKRTzmeQVo9Uan/Pyzar0NTredH+0QWJlX2vS02xmPLds7h9naw z/O5CoxgNHVxxarRLPgU5MzzhpPCu7OOmrdsXh9O2T7AWyssbLFNzgiqdsv5kbmvF6m6 bthK2z0Lz5uWJq7cqzVQ+EhfW8DbkqxyPOnYgZ6KQwqa25gC1Rxb6KfQevE0C1BbJsvD V+QA== X-Gm-Message-State: AOAM530hOdxj/zfu3u3Bb0wJ/j5wKfR57lJF311UJWvkyJffA/npXGIH dOQq4JLMtDN+2Po8kEg6ot4UDw== X-Google-Smtp-Source: ABdhPJzsDpIAFZdAVyZSeNN1AbilssFPYS18T08jYFMkZBimASM09m3/nOWHrLqLxwQl/aAcOMy89g== X-Received: by 2002:a05:600c:a03:b0:38c:f953:ae13 with SMTP id z3-20020a05600c0a0300b0038cf953ae13mr4096297wmp.99.1650633642488; Fri, 22 Apr 2022 06:20:42 -0700 (PDT) Received: from localhost.localdomain (178-190-170-214.adsl.highway.telekom.at. [178.190.170.214]) by smtp.gmail.com with ESMTPSA id p16-20020a05600c359000b00393dcff7a91sm756416wmq.34.2022.04.22.06.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 06:20:42 -0700 (PDT) Message-ID: <8d54fcdc3ea562e2fd1ada68997aa7377bda5187.camel@cybertec.at> Subject: Re: logical replication worker can't find postgis function From: Laurenz Albe To: Willy-Bas Loos , pgsql-general Date: Fri, 22 Apr 2022 15:20:41 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-5.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2022-04-22 at 13:25 +0200, Willy-Bas Loos wrote: > I'm using logical replication on postgresql 13. On the subscriber, there's a trigger on a table that calculates the area of the geometry that's in another column. > I enabled the trigger with > ALTER TABLE atable ENABLE ALWAYS TRIGGER atrigger; > > But the logical replication worker can't find st_area: > 2022-04-22 13:14:11.244 CEST [1932237] LOG:  logical replication apply worker for subscription "ba_acc1" has started > 2022-04-22 13:14:11.282 CEST [1932237] ERROR:  function st_area(public.geometry) does not exist at character 14 > 2022-04-22 13:14:11.282 CEST [1932237] HINT:  No function matches the given name and argument types. You might need to add explicit type casts. > 2022-04-22 13:14:11.282 CEST [1932237] QUERY:  SELECT round(st_area(NEW.epsg28992_geom)) > 2022-04-22 13:14:11.282 CEST [1932237] CONTEXT:  PL/pgSQL function util.location_extras() line 3 at assignment > 2022-04-22 13:14:11.285 CEST [1562110] LOG:  background worker "logical replication worker" (PID 1932237) exited with exit code 1 > > The trigger works well when I fire it in a normal update query. > How can this happen and how can I resolve this? The trigger function is bad and dangerous, because it relies on the current setting of "search_path". You notice that with logical replication, because "search_path" is empty to avoid security problems. Fix your function: ALTER FUNCTION trigger_function() SET search_path = public; Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com