Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iUBQm-00011b-31 for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Nov 2019 15:16:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iUBQk-0005Dz-SU for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Nov 2019 15:16:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iUBQk-0005Dr-Hn for pgsql-bugs@lists.postgresql.org; Mon, 11 Nov 2019 15:16:38 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iUBQd-0002KK-NG for pgsql-bugs@lists.postgresql.org; Mon, 11 Nov 2019 15:16:37 +0000 Received: by mail-wm1-x344.google.com with SMTP id f3so13570152wmc.5 for ; Mon, 11 Nov 2019 07:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Yz3f1/n0PA7zAkCT0xZMTLGGJHYUVjmoYATO21ZjGg8=; b=hT+vB9EWreTBcz8/4wVNR3f6RnSRpvL3TqyQAh3xlWXr6mOaO1c3GVCjBr0lPhc90Z XDXJ2WtY009HcMdu1YDbDXf8DvpnrpJLm84gwBs+r+k88Q0K271tud7Mex2H4BGZKN3V 1VLzInXd1ET1AqHMnseZ14rsRy3Py2SWgr+MeCIxbUCYYyQ7I56bvKohWhHIAQpWn+nw tuOeNHHDuO9p+yRSUZbFfV3z06mrS5Xd3l3HDMoyXscRodTvRMTEFtQ5EZoRxzY/nU8H rPmmoCbBuDRfFwLrFZafyszHIWMkJu8xoP95cN+vsshebB0iPpPVmxlwZ9Fkg8rRiL+c RKTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Yz3f1/n0PA7zAkCT0xZMTLGGJHYUVjmoYATO21ZjGg8=; b=ci9ri1RH8PaQSy6R+sWbYxF9BG2EGFiZmYrB/Ni91KmxbKNLCzS9AEfzvafbIQTnFo VPqa5x7ztxPuu0NF6Tpf49Gy2/okSoK4HNdC7EZzneavJks6/cr4K1C5VSRyGRUxyTtB l01tYTxYATQvhK7p21V+XKfBeKwfKRLGcSuzs9n2/5knWn+ndjAXOXUyJ/vODI5teaAs rl/wN/i0mh/+k3y37YNmGjUIDyCm4jUnnpuPWTHuW6QWeT8+hm72gcEBtP6Cj7udOg/X yXm+ifqUcmwewqy3uI+xIQnY7uQaIYO4z2qyfLJv0vKYH792YeZCaLXu8mDco2ITG/mY m/fg== X-Gm-Message-State: APjAAAXOl6ebldo8ioYctuWD7kUYBLFSx07Zufjg38BfJo0e8czLsn+r oo03SnkleFs6znyR0J5iyn5BwA== X-Google-Smtp-Source: APXvYqzsYEaOKgh5jrbotQHA5oZL+NpiyLfnOwVS63N661rdklU+DKwaaYIMVdGLVfxqrtkZUUgohA== X-Received: by 2002:a1c:a404:: with SMTP id n4mr20347095wme.135.1573485388836; Mon, 11 Nov 2019 07:16:28 -0800 (PST) Received: from localhost (gww50.internetdsl.tpnet.pl. [80.52.202.50]) by smtp.gmail.com with ESMTPSA id f13sm15512671wrq.96.2019.11.11.07.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:16:27 -0800 (PST) Date: Mon, 11 Nov 2019 16:16:25 +0100 From: Tomas Vondra To: James Coleman Cc: Thomas Munro , PostgreSQL mailing lists Subject: Re: BUG #16104: Invalid DSA Memory Alloc Request in Parallel Hash Message-ID: <20191111151625.3kdtri34xce4t5y4@development> References: <20191109182735.ewficcv2hibbyzl4@development> <20191110172925.mlkglpwzwego3wtp@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Nov 11, 2019 at 09:14:43AM -0500, James Coleman wrote: >On Sun, Nov 10, 2019 at 4:09 PM Thomas Munro wrote: >> >> I think I see what's happening: we're running out of hash bits. >> >> > Buckets: 4194304 (originally 4194304) Batches: 32768 (originally 4096) Memory Usage: 344448kB >> >> Here it's using the lower 22 bits for the bucket number, and started >> out using 12 bits for the batch (!), and increased that until it got >> to 15 (!!). After using 22 bits for the bucket, there are only 10 >> bits left, so all the tuples go into the lower 1024 batches. > >Do we have this kind of problem with hash aggregates also? I've >noticed the temp disk usage pattern applies to both, and the buffers >stats shows that being the case, but unfortunately the hash aggregate >node doesn't report memory usage for its hash or buckets info. Given >it's not a join, maybe we only need buckets and not batches, but I >don't know this part of the code at all, so I'm just guessing to >assume either way. > I don't think so, because hash aggregate does not spill to disk. The trouble with hashjoins is that we need two independent indexes - bucket and batch, and we only have a single 32-bit hash value. The hash agg is currently unable to spill to disk, so it's not affected by this (but it does have plenty of issues on it's own). There's work in progress aiming to add memory-bounded hash aggregate, but I think the spilling is supposed to work very differently there. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services