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 1qG3ef-00033w-1F for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Jul 2023 20:26:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qG3ed-0005js-T6 for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Jul 2023 20:26:43 +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 1qG3ed-0005ji-Ix for pgsql-hackers@lists.postgresql.org; Sun, 02 Jul 2023 20:26:43 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qG3ea-001okE-1H for pgsql-hackers@lists.postgresql.org; Sun, 02 Jul 2023 20:26:42 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3fba5a8af2cso37376085e9.3 for ; Sun, 02 Jul 2023 13:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1688329598; x=1690921598; 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=06V4cvkTmNImMaG/qpxXymRYzfOnqMuBGUVhlUCK4eQ=; b=fVrtYJPdU0Z/D++zABntpD6aJdJBi1MYRG89dDTyGHE18SZkfZmwJ3DTaXAYgsLhNy e/3h1ySSXndgIxCyVRP7WH4QJBm2Z8eYBQIzdBgHr/L2dct4vC47GxRPFTMPGgVphM8C tTmxSWzYeP2kO1y8h9m5cB50252vrLPJESIEyUXBumY+tW8WfNvN3sRSozuRv/a8Pw6B 7oXbRWT6YxFYxUWsEp2sZZ7NGJTATDxZLyFgBF2J9LnZ+6LQmnQFYpvShO44kMnm3ecV 39N7/osnfcClC5TSXaBYakGn7dpuR12ojRXFwdO6QccvnFLtAV3rTwEDx2TW1HZRY3Xx 1YuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688329598; x=1690921598; 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=06V4cvkTmNImMaG/qpxXymRYzfOnqMuBGUVhlUCK4eQ=; b=k8Vt9RTFZR5GOdH3aQO7B5GGnO/RX9jhaVmUtIx4i6pjA6//jgKpXjex3DCyjIMdAm s9FTLO4kF9hznLnPVT1Dqut0PXU1LvCv3tRW4+xEpu/vjVfEhskfDZ07EbuK2KGVEHm0 BIOMc6eRYPhCjtBWgGEKJGmlAgSm6UJkIdhE/XAH3pGAaXj1S+bP2BugNv5yYr5Fd0Bt /iexlZ10kMpv3BIeW1W+LSOuSgtJmmmwcZt3emdEzCQqWrRrarXxDra21rOJvaXpJgOu OlOXJ/X616sjGFasCIAIqunxDwsfLnv+rjWU6CbIWZEhK2lVJOZrCQAqHZxEpxlb/xzn Vcig== X-Gm-Message-State: AC+VfDwiFBepmIIVby4KEY6kUWR2eygpjXejxYH8tnGkyLknGubwPRZC P3CXA7LsB50qchcCnsftu6RdDmuEuJiMwhyRHSc= X-Google-Smtp-Source: ACHHUZ6/JWI7VvBv5ZfiX8/KIEOcUU2Lmu4DCwn8oIGXWkpNddvh8W8S2JhQn91YvZurW4yHcObGMQ== X-Received: by 2002:a1c:4c10:0:b0:3fa:991c:2af9 with SMTP id z16-20020a1c4c10000000b003fa991c2af9mr6076020wmf.16.1688329598544; Sun, 02 Jul 2023 13:26:38 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-228-220.bb.vodafone.cz. [86.49.228.220]) by smtp.gmail.com with ESMTPSA id 6-20020a05600c230600b003fbc4621839sm8127088wmo.0.2023.07.02.13.26.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Jul 2023 13:26:37 -0700 (PDT) Message-ID: Date: Sun, 2 Jul 2023 22:26:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: memory leak in trigger handling (since PG12) Content-Language: en-US To: Alexander Pyhalov Cc: Andres Freund , Tom Lane , PostgreSQL Hackers References: <222a3442-7f7d-246c-ed9b-a76209d19239@enterprisedb.com> <960113.1684859980@sss.pgh.pa.us> <20230524185559.un4dqfem3u3ktons@awork3.anarazel.de> <36e564f7-6cde-927d-9089-19471a05e8f3@enterprisedb.com> <48e251869b7ef921b7f894a3c7cb154a@postgrespro.ru> From: Tomas Vondra In-Reply-To: <48e251869b7ef921b7f894a3c7cb154a@postgrespro.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/23/23 08:03, Alexander Pyhalov wrote: > Tomas Vondra писал 2023-06-22 17:16: >> On 6/22/23 13:46, Tomas Vondra wrote: >>> ... >>> >>> I haven't tried the reproducer, but I think I see the issue - we store >>> the bitmap as part of the event to be executed later, but the bitmap is >>> in per-tuple context and gets reset. So I guess we need to copy it into >>> the proper long-lived context (e.g. AfterTriggerEvents). >>> >>> I'll get that fixed. >>> >> >> Alexander, can you try if this fixes the issue for you? >> >> >> regard > > Hi. > The patch fixes the problem and looks good to me. Thanks, I've pushed the fix, including backpatch to 13+ (12 is not affected by the oversight, the bitmap was added by 71d60e2aa0). I think it'd be good to investigate if it's possible to compute the bitmap only once - as already suggested by Andres, but that's a matter for separate patch, not a bugfix. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company