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 1pxxRG-0004cs-Pj for pgsql-hackers@arkaria.postgresql.org; Sat, 13 May 2023 22:10:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pxxRF-0004y0-Au for pgsql-hackers@arkaria.postgresql.org; Sat, 13 May 2023 22:10:05 +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 1pxxRF-0004xf-11 for pgsql-hackers@lists.postgresql.org; Sat, 13 May 2023 22:10:05 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pxxRB-002Y7V-6g for pgsql-hackers@lists.postgresql.org; Sat, 13 May 2023 22:10:03 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-50db91640d3so9241691a12.0 for ; Sat, 13 May 2023 15:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1684015800; x=1686607800; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=oWj0cpP7Y6070doxGEsP5ZgNqkcS9cZHPO+64FPGOWk=; b=hokhEkOWDC50QmBTCPATK+ZhbOfmyREGYEiOOIsAznwb3G2aqbRjv5ulvzT9NuFTNg tQaRokM1XXHhUeH34/68Ky4gPtGYxjcn+PgbYcCkyMVAmL9OmwodhRucnI5IJohxqFNi Bxrs5xGD8yK6B0NRo0gdMwm4CJl9jn/Plj3avexI64fB1C7qG4CUnQze6Kmy841FPZXy l8rOroVQ/TuSa+zydR+yb1ZlpzkZEF80Z5NHi0b7ir0bZFri+JxEhkBbwovJOEJr8tY1 hfm1nwEAdbhsRu1jFaMqbcE9l5sEoOHZx359bXkUK+jaxXbaR9h3HzeNM9tUHWMmzfp/ OEjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684015800; x=1686607800; h=content-transfer-encoding:in-reply-to:from:references: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=oWj0cpP7Y6070doxGEsP5ZgNqkcS9cZHPO+64FPGOWk=; b=Lh4GE4dKTzQaiH3zPVsMU3CQINc5Zt6EXoLY5/Xnz006bXiO/DqkUZGTCz0eZzY1hS cnkVnT4LbFt84pD4NJ7hcuX1GnigXFXdgpdOYFZat7CTeUW0mSKSXcw9+tgkEB2CTuAA s/h6mCwq2kWmvIB9FfQjEpOypdhbUyF+0xRo09MygyiaO6mJjdwYo8bA/Sj3ZfnbLMo2 Sth2OzarjwCDbpJgmopreZdyVwDrliaYmS0TgWzqAjXOeO+UlSzKB+NWa4uQjFI8SN/I f9WaiYKpF1MpZsrl3QGzz/NnG1zUevHnOKz8U8kK11D6fGnYO5HlNaCOXFqs2syzihaH Kgqg== X-Gm-Message-State: AC+VfDzH2we5fdJQR+yLSCvXkcBkXSG82Jb705pb0hZMHzoBf5obesTb tVNRc26iEHlLinZrCf4PqhSOxZ8rXTYRuGNVxmCvfYien5gyhQVd/g9kUqnuSuuPIkv1lMnqcpF FSbKhHqI9ZYpL9iRGgp3h44iyJ8Osk7nWkwJ2qLG3YJ0qe6yIS3L2HG3F9Z93HsrtbSx85GmFHv UcZ6Emk4P9Hyk2I1oGIBXwbO2kIlnXjdNa0KsDCOSNOiouVUWcWDGR X-Google-Smtp-Source: ACHHUZ4KmYKSmTq9XivFcSf3lM3QPQqtPD9n6dymaAcFkVNWxBpR15htG/6Zm8OgbI7QatTgsWhlkQ== X-Received: by 2002:a17:907:9810:b0:96a:861:a2ac with SMTP id ji16-20020a170907981000b0096a0861a2acmr15071218ejc.0.1684015800033; Sat, 13 May 2023 15:10:00 -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 h10-20020a1709070b0a00b00965ac1510f8sm7257335ejl.185.2023.05.13.15.09.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 13 May 2023 15:09:59 -0700 (PDT) Message-ID: Date: Sun, 14 May 2023 00:10:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: Memory leak from ExecutorState context? Content-Language: en-US To: Jehan-Guillaume de Rorthais , pgsql-hackers@lists.postgresql.org, Konstantin Knizhnik , Thomas Munro References: <20230327231323.08277083@karst> <20230328151745.0f6061f8@karst> <20230331140611.3695d30d@karst> <20230408020119.32a0841b@karst> <20230504193006.1b5b9622@karst> <20230508155648.lzddwywo6emote2b@liskov> <20230510142419.6185a492@karst> <20230512213606.isxoy2s57majc4ji@liskov> From: Tomas Vondra In-Reply-To: <20230512213606.isxoy2s57majc4ji@liskov> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/12/23 23:36, Melanie Plageman wrote: > Thanks for continuing to work on this. > > Are you planning to modify what is displayed for memory usage in > EXPLAIN ANALYZE? > We could do that, but we can do that separately - it's a separate and independent improvement, I think. Also, do you have a proposal how to change the explain output? In principle we already have the number of batches, so people can calculate the "peak" amount of memory (assuming they realize what it means). I think the main problem with adding this info to EXPLAIN is that I'm not sure it's very useful in practice. I've only really heard about this memory explosion issue when the query dies with OOM or takes forever, but EXPLAIN ANALYZE requires the query to complete. A separate memory context (which pg_log_backend_memory_contexts can dump to server log) is more valuable, I think. > Also, since that won't help a user who OOMs, I wondered if the spillCxt > is helpful on its own or if we need some kind of logging message for > users to discover that this is what led them to running out of memory. > I think the separate memory context is definitely an improvement, helpful on it's own it makes it clear *what* allocated the memory. It requires having the memory context stats, but we may already dump them into the server log if malloc returns NULL. Granted, it depends on how the system is configured and it won't help when OOM killer hits :-( I wouldn't object to having some sort of log message, but when exactly would we emit it? Presumably after exceeding some amount of memory, but what would it be? It can't be too low (not to trigger it too often) or too high (failing to report the issue). Also, do you think it should go to the user or just to the server log? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company