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 1swni0-00678E-5m for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Oct 2024 19:11:24 +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 1swnhz-004Zns-FD for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Oct 2024 19:11:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swnhy-004Znk-Rr for pgsql-bugs@lists.postgresql.org; Fri, 04 Oct 2024 19:11:23 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swnhu-002YIK-UB for pgsql-bugs@lists.postgresql.org; Fri, 04 Oct 2024 19:11:22 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 67B08C0002; Fri, 4 Oct 2024 19:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1728069078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I32xJRlH25bvqdhA9/MOfpwVsDJYuKlDVlabFYaxB6Q=; b=KuT7rqwlZT5Gw22DnFKby0FaXA73FFC0WFpOZ1pVdZ6NhES390hCtFMg3x/Oog0EqdwqK3 SUYMf/FE50dZbzESgPX7+CkJ/GOIToRzYeyujfUYSfzspwTQpG31nhKjuFTUqQ5E6zN/md ZDroOY1d1VantR85vy0NDbGG93txYiCNIi4HxuMINZ/KcMQe1GaME72/3c6MoLQsJJOyqF SK0mVNcL3FyMhYSWD/9bOcTjF5j6z7xrb+9C4y8Grq3g0/P9FxbKZQlHMmjuHYSs/BdqIy ABZIu2V6EXj33mb0lk+6Spn/drGiFfu0YZ/KO9+luVuJ0zRDM9BODxdyg6xXag== Message-ID: <82ffe6ad-a219-4255-9fea-daff619a1ca0@vondra.me> Date: Fri, 4 Oct 2024 21:11:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: PostgreSQL 17 Segmentation Fault To: Cameron Vogt , Michael Paquier , Sean Massey Cc: "pgsql-bugs@lists.postgresql.org" References: <6aca4816-be12-4f54-9eba-8c9b55cdc801.094840f8-2c1e-4d5a-9984-8ac00be38080.9eae5fd3-5d56-4ffb-9d4c-3e272ee57cba@emailsignatures365.codetwo.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Thanks for the provided information. Per the backtrace, the failure happens in the LLVM JIT code in nestloop/seqscan, so it has to be in this part of the plan: -> Nested Loop (cost=0.42..6074.84 rows=117 width=641) -> Parallel Seq Scan on tasks__projects (cost=0.00..2201.62 rows=745 width=16) Filter: (gid = '1138791545416725'::text) -> Index Scan using tasks_pkey on tasks tasks_1 (cost=0.42..5.20 rows=1 width=102) Index Cond: (gid = tasks__projects._sdc_source_key_gid) Filter: ((NOT completed) AND (name <> ''::text)) But it's not clear why this should consume a lot of memory, though. It's possible the memory is consumed elsewhere, and this is simply the straw that breaks the camel's back ... Presumably it takes a while for the query to consume a lot of memory and crash - can you attach a debugger to it after after it allocates a lot of memory (but before the crash), and do this: call MemoryContextStats(TopMemoryContext) That should write memory context stats to the server log. Perhaps that will tell us which part of the query allocates memory. Next, try running the query with jit=off. If that resolves the problem, maybe it's another JIT issue. But if it completes with lower shared buffers, that doesn't seem likely. The plan has a bunch of hash joins. I wonder if that might be causing issues, because the hash tables may be kept until the end of the query, and each may be up to 64MB (you have work_mem=32, but there's also 2x multiplier since PG13). The row estimates are pretty low, but could it be that the real row counts are much higher? Did you run analyze after the upgrade? Maybe try with lower work_mem? One last thing you should check is memory overcommit. Chances are it's set just low enough for the query to hit it with SB=4GB, but not with SB=3GB. In that case you may need to tune this a bit. See /proc/meminfo and /proc/sys/vm/overcommit_*). regards -- Tomas Vondra