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 1oMwdu-00026b-3o for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Aug 2022 19:17:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oMwds-0000nV-Om for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Aug 2022 19:17:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oMwds-0000hK-Aj for pgsql-hackers@lists.postgresql.org; Sat, 13 Aug 2022 19:17:52 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMwdo-0003vR-Vr for pgsql-hackers@lists.postgresql.org; Sat, 13 Aug 2022 19:17:50 +0000 Received: by mail-il1-x135.google.com with SMTP id d4so2068403ilc.8 for ; Sat, 13 Aug 2022 12:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc; bh=J8hJgBzqR6iKA6OHsuVr3JLYCzjNtdf/Xl9Ojhb2rps=; b=pI/mNXYhuOdlqb7ItWzJQxnITBoQxpt/Qw1gtpZ/t4Ce4So7/5jq+bJ95IIL9U2803 csWiYGa3+J76C/nrXgj7xh6lcBrencBEyWUdmdmbKL7F3OGZORKSWb38qXpny33XRa5T tGvJ56AFIwCJadM8/3fR8kt0QlVwFiJD3/kdfqQn55Eh/BSx1aIkMAVmSUC6JkK0bZh5 FI5suWsac63nxzgz42yP4i9gm3Gt5jXjx4AmCljZ90L5MV5Y7fmOU+ZRh39NT3Q9OhDt WQjAL2vPVN93iW6bHw4qryD0XRN+sx45yke0mArKCw+TUHHn2iUxzL92BYmphLKPMlpQ oH1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=J8hJgBzqR6iKA6OHsuVr3JLYCzjNtdf/Xl9Ojhb2rps=; b=gi0PRAgkcRmCSgRi7bAvpTTjK+iA+qykDY1R8oHxOXrChAtM8WMWEibFyWLe00CKOo U2P2DBKGvw5tQ0NO9ckUFfpr49FXJQlZyiXy6O/NXdJtwPrhlV1ZArsM6WPy/tv2kAa6 ULJyb4WPChm21u9CUqkYvw6CEInDKopnUGpA7jzFpewjJnkmw7Krgh9VJ6CLiuBiCkMK f8t6y1vDpuh6QKToDiP998CytkfvyGMVHzu2i+yVzrCcYzS72ypJxLcNp5ZE99aXHCfW UOjWhkC4qf3vADpNeD8i03ImmrZ1hE+rqXvjbG4cvxeIVQwIZlpH9HIV1vhMsJLDErfR CJlw== X-Gm-Message-State: ACgBeo3SMWRXsiI//ui6QQpAbqfcuj1YzdxWATGW+6uA8JND/XiDgql8 PA2W/NbY1ku6Y7x+EVdRtKiKbQ== X-Google-Smtp-Source: AA6agR6c2QEgb4PuxY75pxlrhR7gciZ6sO2vmhAsqYHNycwmSJ6dD7Jl9BiWlJVPu/NvV7vcJYUaTw== X-Received: by 2002:a05:6e02:1e09:b0:2df:7b07:861e with SMTP id g9-20020a056e021e0900b002df7b07861emr4092152ila.162.1660418267851; Sat, 13 Aug 2022 12:17:47 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h2-20020a056602154200b0067c028ef1d6sm2554912iow.52.2022.08.13.12.17.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Aug 2022 12:17:47 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id C21D78007F2; Sat, 13 Aug 2022 14:17:46 -0500 (CDT) Date: Sat, 13 Aug 2022 14:17:46 -0500 From: Justin Pryzby To: Zhang Mingli Cc: pgsql-hackers@lists.postgresql.org, Tom Lane Subject: Re: [patch]HashJoin crash Message-ID: <20220813191746.GI26198@telsasoft.com> References: <9746d4e1-a008-44a3-bce9-170b4721e862@Spark> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk + Tom Lane On Fri, Aug 12, 2022 at 11:05:06PM +0800, Zhang Mingli wrote: > I got a coredump when using hash join on a Postgres derived Database(Greenplum DB). > And I find a way to reproduce it on Postgres. > > Root cause: > > In ExecChooseHashTableSize(), commit b154ee63bb uses func pg_nextpower2_size_t > whose param must not be 0. > > sbuckets = pg_nextpower2_size_t(hash_table_bytes / bucket_size); > > There is a potential risk that hash_table_bytes < bucket_size in some corner cases. > > Reproduce sql: