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 1o2KPi-0000XX-27 for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jun 2022 22:26:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o2KPf-0008Hc-82 for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jun 2022 22:25:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2KPe-0008GI-Qd for pgsql-hackers@lists.postgresql.org; Fri, 17 Jun 2022 22:25:58 +0000 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o2KPa-0005Ni-1Y for pgsql-hackers@postgresql.org; Fri, 17 Jun 2022 22:25:56 +0000 Received: by mail-il1-x12c.google.com with SMTP id h7so3847455ila.10 for ; Fri, 17 Jun 2022 15:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uAD/w5pEZrtifp/Y9RkBwcxr8hcu7qolXYCkzFnGYXQ=; b=YlZ3l8Xems658fPmRIIMCVBUGu00je0iBByFkQwza087t1EGlIpKBbr4eYz8cABXwu cQrHebhxZV85+YuPu/JPrqo7i/aKOa6lRIEUF2W6DrUOeFmfoF4XUaE3bFKZ+s5lNckb GC+Hj8/PoV6gOlD9raBF5wngH/++KK6Go4C1jxsyvcpAClnWcIUBN0pGtaYrNV2H9H7B I1xrBgn3MnFPPuSFFOWkhFjzdq0baNYvvBN6AkGdigO+RUgyI0SR41QEMdo21KckAgTE Hucag0vpgJJtpGesbzxx/GGXGlXR4FghPRPNexXTmVH1Fz3YP1VwpuHKZzXpe37lWGpX S0+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uAD/w5pEZrtifp/Y9RkBwcxr8hcu7qolXYCkzFnGYXQ=; b=sxAbDR5yLCyI72zksTnFIyhIgn5xwk3mgCBTe4ndEnmXDl8s+RBRBvRdY9/qpYc1Am NehI5JpjF5D/WVAb96mYAWKlgB7sPG3HPYgM2uX/YgUHi85ez5BuSw44uM2JAD33BPbI JrCFZ7OVk9H+s1UE16ZAOkXHU9GL6nZKSzwECdxN54v+42KMpXsDibDQ3hHDn+6Ki0wL q+CO90MSICKWMJSIEJLoFRy7jysDGsP2bhcz0Qq9A1CSffxaG7+eISU4eiHzNclurIY9 +A73Yy/rKRpSGxBGG4ilhR4nm2+a7IeiAQwJ+uUi1QBvJcFJLULUKG6qBWfefrj/fnje dUFA== X-Gm-Message-State: AJIora8DK5voG1oRRSnJZjrtUPO7TqWpwXrtQGg+TE5ZHzIR7VduRt1e A2B8aUpItwKfc3+MnAZCuSCwpg== X-Google-Smtp-Source: AGRyM1splfhQzx3W4IwDmnTRmGcIHDw+wyEEuAvQlQk+LLuEjfaup0gBrg7rymelsusABHyE0z8IUQ== X-Received: by 2002:a05:6e02:1521:b0:2d1:5e40:b94b with SMTP id i1-20020a056e02152100b002d15e40b94bmr6685593ilu.182.1655504751230; Fri, 17 Jun 2022 15:25:51 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z14-20020a056e02088e00b002d11888a1acsm2876552ils.34.2022.06.17.15.25.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2022 15:25:50 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id C5DEF800AF9; Fri, 17 Jun 2022 17:25:49 -0500 (CDT) Date: Fri, 17 Jun 2022 17:25:49 -0500 From: Justin Pryzby To: Michael Paquier Cc: Robert Haas , Tom Lane , Tomas Vondra , pgsql-hackers@postgresql.org Subject: Re: should check interrupts in BuildRelationExtStatistics ? Message-ID: <20220617222549.GI29853@telsasoft.com> References: <20220509000108.GQ28830@telsasoft.com> <3592964.1652067393@sss.pgh.pa.us> <20220603152837.GO29853@telsasoft.com> <20220605014233.GR29853@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nqkreNcslJAfgyzk" 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 --nqkreNcslJAfgyzk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 06, 2022 at 04:23:34PM +0900, Michael Paquier wrote: > On Sat, Jun 04, 2022 at 08:42:33PM -0500, Justin Pryzby wrote: > > The fix seems to be to CHECK_FOR_INTERRUPTS() within multi_sort_compare(). > > That would supercede the other two CHECK_FOR_INTERRUPTS I'd proposed, and > > handle mcv, depends, and ndistinct all at once. > > Hmm. I have to admit that adding a CFI() in multi_sort_compare() > stresses me a bit as it is dependent on the number of rows involved, > and it can be used as a qsort routine. That's exactly the problem for which I showed a backtrace - it took 10s of seconds to do qsort, which is (uh) a human timescale and too long to be unresponsive, even if I create on a table with many rows a stats object with a lot of columns and a high stats target. --nqkreNcslJAfgyzk Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-wip-check-for-interrupts-during-extended-stats.patch" From 1c5fe1fb1cf4d2e38cf3b8edef1288cb63388cc4 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Sun, 8 May 2022 19:36:43 -0500 Subject: [PATCH] wip: check for interrupts during extended stats It's possible to handle this partially by adding CFI at higher levels (statext_dependencies_build and statext_ndistinct_build), but in order to handle MCV, CFI has to be done at a low level here. --- src/backend/statistics/extended_stats.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index cb0a22b73e8..c6ba352e414 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -894,6 +894,8 @@ multi_sort_compare(const void *a, const void *b, void *arg) SortItem *ib = (SortItem *) b; int i; + CHECK_FOR_INTERRUPTS(); + for (i = 0; i < mss->ndims; i++) { int compare; -- 2.17.1 --nqkreNcslJAfgyzk--