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 1sykKk-001tCd-Tr for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2024 03:59:27 +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 1sykKj-00AXG5-Lr for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2024 03:59:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sykKj-00AXEr-DL for pgsql-bugs@lists.postgresql.org; Thu, 10 Oct 2024 03:59:25 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sykKd-0008sz-4h for pgsql-bugs@lists.postgresql.org; Thu, 10 Oct 2024 03:59:24 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-7e9fdad5af8so292490a12.3 for ; Wed, 09 Oct 2024 20:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728532758; x=1729137558; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YHFOoGQUYSZobRDpKXh8AVkCg9x2i5he0rVqwTk1y34=; b=Vr3ictahS7WCBXTwq8z7TSAtOFvRk6SEoccDKDr4I0+AQbTTYFGF9B8sAtnxawI5NN 6sfvEuEh86lU0s2TJ7ku/JILR6ruKqesJXEDyRDBtAHtNr91oKP0+xvHMauIc6WbsMzg S5hdTYsgW1hrA7CmsS21Ki+MB/iurPZ432EV+daOIFJyLfZw+O3CIJW7hUlFb81yDo05 mk9DKAnEFvQE/WLOCrXSOADmDaelw5PoI4TBHsHDn2fBXjUEIAU9y6oHBImqE7VW0PSj tcI7qCH3NzvAm26uNExx69YzijZ+YfU0p7Up26GRRKGUicWHH0kZj+XXiEv5XP1JNhXo 5wnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728532758; x=1729137558; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YHFOoGQUYSZobRDpKXh8AVkCg9x2i5he0rVqwTk1y34=; b=ZBo7lQAKSMJSjySM+tl5v3Dtmz4uAxzVAmSMYCFI7RZWsXM6/58WMyNf1S2YvT/lkl u++QsE86KY461M8TZXZ3wNL7XSqoD9hezC4iMfi/X0zqEoK/FJNYnzhyUKPm6ES8d0Wk gFc22BhayIFfWxzI9DJxq38L5vHSmiPUxUWVDVVfO3g+/N3rJjWQs48INpFxr+XcccY1 1xbEDvCkz7DJhA+kO7mWYtMD7pI0h61IDnZcN11HPIx5PmV4SFfHGcuC3S6jRl12TUQe xtIHVxZu8l4CTQuKKgc/rQBUXrOGsP7U5lxIcMAYD3OIYJeuhp4DMzMcKzug0Tzqejzj 33qg== X-Forwarded-Encrypted: i=1; AJvYcCWaZtsVqfE9NKaLK3/4YPRZj9Zb/iPf/vlTLA5Ih0NFkbLRsNbRo6uVV/nPW+PkuVIRt2P2OpYgsYO4@lists.postgresql.org X-Gm-Message-State: AOJu0Yyq1I5GcB0R64KGvB7CmxmazvASuZ5L2t2IJW1KgeNk2Nk8aQv0 fAD+Indq0IDIqGsFOzDhBFS3Z45M2+K1qybs7Mi1xoibA572hLMw X-Google-Smtp-Source: AGHT+IFJ0cuZV8EVUwof05LVSUONSB1gBIfhYAv9lhwB3RBy69z4vPXLfRjkrmjdNdkE6N+l/h25ug== X-Received: by 2002:a17:902:e5d2:b0:20b:8c13:5307 with SMTP id d9443c01a7336-20c637565ebmr61229865ad.33.1728532757933; Wed, 09 Oct 2024 20:59:17 -0700 (PDT) Received: from [10.10.20.104] (node-t06.pool-101-109.dynamic.totinternet.net. [101.109.146.214]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c0e74fasm1687815ad.153.2024.10.09.20.59.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Oct 2024 20:59:17 -0700 (PDT) Message-ID: Date: Thu, 10 Oct 2024 10:59:13 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Reference to - BUG #18349: ERROR: invalid DSA memory alloc request size 1811939328, CONTEXT: parallel worker To: Craig Milhiser Cc: Thomas Munro , Tom Lane , pgsql-bugs@lists.postgresql.org References: <2878480.1727017360@sss.pgh.pa.us> <6785e9e8-4c64-41b0-9e72-c13d1822b599@gmail.com> <0c3b0e1b-55d1-42b6-8c3c-4392479187db@gmail.com> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/9/24 23:28, Craig Milhiser wrote: > On Oct 8 Andrei Lepikhov wrote > > I'm a bit confused: the thread subject named ' invalid DSA memory alloc > > request size ...', but you write about issue with OOM killer. It is two > > different issues, which one do you have exactly? > > > I started with the Invalid DSA memory allocation error. I was asked to > try an experimental patch above. Then I got OOM with the patch only > running parallel. You will see below, there was an OOM but I do not > believe it is the query. So, I think the patch works, but you found out one more issue at the same query. Awesome! > I ran a new test on an instance with 512 GiB of memory.  After I applied > the patch, the Invalid DSA memory allocation message was not > replicated.  Running max_parallel_workers_per_gather = 0, the query took > ~9.5 seconds and used <1 GiB of memory.  With > max_parallel_workers_per_gather = 2 the query used  ~170 GiB of memory, > ~70 GB of temp files were written and the query ran for more than 1 hour > until I ran out of disk space. It's fascinating. I have one user report like that, but they also didn't provide any synthetic test. I think it is almost impossible to create such reproduction without a minimal understanding of what's happening. I can imagine only a data skew or a logical bug in this part of the code. But without direct perf and gdb touch, it is hard to resolve the issue by just gazing into the code. Additional actions can provide some food for thought: 1. If you remove aggregates (STRING_AGG, count) from the selection list, will the problem remain? What about OFFSET 0? 2. Can you build extended statistics on account_id,disabled,user_type_id and provide an explain (and explain analyse)? 3. Can you use pg_query_state (unfortunately, it needs a patch and re-compilation) and show us intermediate execution state snapshots? 4. I see a duplicate clause in the query: SGM.OBJECT_ID = U.OBJECT_ID. For what reason you have it here? can you remove it from the query? 5. One more wild guess: can you analyse how much NULLS contains column u.users_id at the moment when HashJoin evaluates clause (u.users_id = cf.user_id)? [1] https://github.com/postgrespro/pg_query_state -- regards, Andrei Lepikhov