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 1t0DtS-00A6kd-Ql for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Oct 2024 05:45:22 +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 1t0DtP-00A7U3-Mh for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Oct 2024 05:45:20 +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 1t0DtP-00A7Tv-Bo for pgsql-bugs@lists.postgresql.org; Mon, 14 Oct 2024 05:45:19 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0DtM-000xGD-DC for pgsql-bugs@lists.postgresql.org; Mon, 14 Oct 2024 05:45:19 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-71e57d89ffaso718664b3a.1 for ; Sun, 13 Oct 2024 22:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728884715; x=1729489515; 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=oSDG+7P5rd2JKjZtsWTJRQRkM5o6SyjhJjMaY1fxYFw=; b=HjTU5MSNI38PfBOkHIWf+xzJWx2qJvr7GAJI4kTadsk40Xh8cJZWfuxsKpc7SxTxj8 6psr1t3BhVhkCFfHYkOxiKPOys5/fzFyzNuiMv6a/nfZkJHMVk30N/u4QAzmswLNo1Cw MaSVggs8LQXrmw1J6UdRlc0gOMCJN0zZk8g+a7g5wVMyefDzgkX5L3r6TQ3enC649aNd qlpwWY5XC/nl4belTnVRKWW95SBXQxQ18Cw9mPeAEZt3b7DHysNfENnjChnHKD6wYL/8 cWyOXQTT0nrRMFfZ2eh/PZA7u+D+/gOp8nJq1EzPkrqbBHihJBqud9Zt1l8O80d9Hq6g QfhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728884715; x=1729489515; 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=oSDG+7P5rd2JKjZtsWTJRQRkM5o6SyjhJjMaY1fxYFw=; b=gy47W1sl6vcYPTuCdKAGHTE3G4RtQPT2COjYIXEjggt9RbGm6KAXGr567fgBQoXwxs aB2DXIT0FimpU4sWEWYSQdyAd16pLCA4XHBgFgQO/jwHFPkGGLS0Lmn54J3yYxQuPs+u aUzeTDPIw12ibiAjTTi/FevOb6zVF0UmiIhquqDnmryscERijIKf1hjjcF4oW06f2it0 O3lU9bmJT+sRf+ij7YmHf8Rhj8xQeeAbj4ioleyEZOBUmfdOedbgvedAFuCb7fWZ4Yp+ GpePnnhTeKxhSRWNP9ylPFPe4LjAFGZBfBIy9I9gUaIb4LIPXqPxgQuABXGl1iR0uylg NUrg== X-Forwarded-Encrypted: i=1; AJvYcCXqDWCLi2X+G2TKBj6vlMl/6cfwHVqN0uQAt7B4pkwa86ICVeQHvLQKKgflI4A2OZVszJNiQ7/GD00H@lists.postgresql.org X-Gm-Message-State: AOJu0YxuLhtsDR+lOXQ00sediu34X7kyDjKHAhezxeGacEZoU2/ARUel X0OUOXKJZArcar3tyEsbiie7WL6b8LpVPPHZs5LxNRgbIQ7Fjw25 X-Google-Smtp-Source: AGHT+IFqHujhfkZ9P/s+CSqIAMRyZPUAinmipNZa7FpykaSSa5/P9r5npVo43kKraaLpAb4LbWOV2A== X-Received: by 2002:a05:6a20:cd8f:b0:1d8:a1dc:b3b with SMTP id adf61e73a8af0-1d8bcf2327bmr13927256637.20.1728884714676; Sun, 13 Oct 2024 22:45:14 -0700 (PDT) Received: from [10.10.20.104] ([1.20.172.122]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20cca05f0cbsm28056335ad.90.2024.10.13.22.45.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Oct 2024 22:45:13 -0700 (PDT) Message-ID: <96a328e9-4fbf-433b-a8d7-071da18e12c4@gmail.com> Date: Mon, 14 Oct 2024 12:45:09 +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: Thomas Munro , Craig Milhiser Cc: Tom Lane , pgsql-bugs@lists.postgresql.org References: <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/14/24 04:08, Thomas Munro wrote: > On Mon, Oct 14, 2024 at 12:23 AM Craig Milhiser wrote: >> I have reproduced the problem with synthetic data. The script is below. Thank you for your patience with me. > > Thanks, repro'd here. At first glance, it looks like it's trying to > load this distribution into a hash table and failing to handle the > skew as well as non-parallel hash: > Getting coffee and looking more closely... Hmm, with reproduction, it is too easy to solve ;) My explanation (correct if I'm wrong): OUTER JOINs allow NULLs to be in a hash table. At the same time, a hash value for NULL is 0, and it goes to the batch==0. If batch number 0 gets overfilled, the ExecParallelHashIncreaseNumBatches routine attempts to increase the number of batches - but nothing happens. The initial batch is still too big, and the number of batches doubles up to the limit. At the limit, parallel HashJoin stops this grow and (I didn't trace this part, just guess) allocates memory for 2097152 batches that causes OOM. To support this chain of thought, you can see the simple example below, which triggers the issue: DROP TABLE IF EXISTS test; CREATE TABLE test (n int); INSERT INTO test (n) SELECT NULL FROM generate_series(1,1E6); INSERT INTO test (n) VALUES (1, 'a'); ANALYZE test; SET enable_nestloop = 'off'; SET enable_mergejoin = 'off'; SET max_parallel_workers_per_gather = 2; SET min_parallel_table_scan_size = 0; SET min_parallel_index_scan_size = 0; SET parallel_setup_cost = 0.001; SET parallel_tuple_cost = 0.0001; EXPLAIN (ANALYZE, VERBOSE, COSTS OFF) SELECT t1.n FROM test t1 LEFT JOIN test t2 USING (n); I think, now it is much easier to find a proper solution. -- regards, Andrei Lepikhov