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 1spAaW-00H94s-7X for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Sep 2024 18:00:09 +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 1spAaV-008d2I-RH for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Sep 2024 18:00:07 +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 1spAaV-008d10-I5 for pgsql-bugs@lists.postgresql.org; Fri, 13 Sep 2024 18:00:07 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1spAaR-0011mv-Ut for pgsql-bugs@lists.postgresql.org; Fri, 13 Sep 2024 18:00:06 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-53659867cbdso1958141e87.3 for ; Fri, 13 Sep 2024 11:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726250403; x=1726855203; darn=lists.postgresql.org; h=in-reply-to:cc:from:references:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Su7TEMqagEiJn1NSqEI5WlQLWXVlS5YIVeMMrKWjTkA=; b=A2PH7LViP0sUar6I2ZUz0bgVbcQVs0y0vKbuDdNAIPxgiYObgX3hIuDyf0wV56+mCt 4ZeV/3j9Pwh49r7jzNgFVC4xe7+/EImfTlRXKLk5EfXuA/rbyv0sCqhuxAoCTWwyHJiL vGpJvvry6q6AqgU6oQRCFv1v+6P8/xcidAH29gDPULgOJNwubNnO4ZWngYB0vcPzrk0b VAfH97U05G8FbdQDumJwGZOj8JlX0nApzpm6NTaFNc6feNo3dbqY5wwbuS3n0FLpwbLR QZLmRDD0Lz6blpbY27HXO8ZlKy8kp/pf7zt8QgnGVK9CWh47fTvdVg/RylMJdPOeW6d7 Q+aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726250403; x=1726855203; h=in-reply-to:cc:from:references:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Su7TEMqagEiJn1NSqEI5WlQLWXVlS5YIVeMMrKWjTkA=; b=Lf5NwLITEPwMOfi8f2ZNWDYnkMAT8rWQ5c8P8j84W4QkHJFQg1xNo5rEoLWYr7fbCh swrMgU4s4pZ8OfhQ3Ue0Tjr5iKscFJT4+VHhNpGYylhFPgxt5YLdh4bYRmCbRfVVyOhE lgwUGi3HE4RAmVvB6vY32ajrHgcC3fbMVRDr1v13EL0v/eKu6g5YxTl1sz2+3HirOXtY ZxcBskp/o/PUhqEF24M7e1nkNNRheUiQxiEG3+rDbY+Cp6XZJ765T/YjMdibeUfVE8D3 TcrHg7IOHflFXhR0lvGETFv6imVtCBT+6Wn3puubQJMsHn03Vnlj0X7bYFi4H3Ahj/SK L00w== X-Gm-Message-State: AOJu0YyfslgnQxzcX7D7XhKSCN/384rtQCSQrsbsGnCEnbLfZ8rNPyXI WVg5IQvK5PXKfsOxWHl4Gu5wwxe4bkynJWN9GrmscHyyRkhu4fLa X-Google-Smtp-Source: AGHT+IEPotfUgF+NRG4DVuRiv3I+BEZy/8uRPDn4rCWkrqONJeThS4udzMhOgoD5QK4SeyIdThawLw== X-Received: by 2002:a05:6512:3b97:b0:536:5810:e89 with SMTP id 2adb3069b0e04-5367ff32443mr3382561e87.49.1726250402002; Fri, 13 Sep 2024 11:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.16.7]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5365f86fd91sm2378544e87.73.2024.09.13.11.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Sep 2024 11:00:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------tzieZZ0xYrn0KOPQEy9ebWXa" Message-ID: <20a57c76-7aaf-a641-add3-147541a4dccf@gmail.com> Date: Fri, 13 Sep 2024 21:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #18616: Long-running hash index build can not be interrupted Content-Language: en-US To: Pavel Borisov References: <18616-acbb9e5caf41e964@postgresql.org> From: Alexander Lakhin Cc: pgsql-bugs@lists.postgresql.org In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------tzieZZ0xYrn0KOPQEy9ebWXa Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Pavel, 13.09.2024 17:51, Pavel Borisov wrote: > > > Reproduced on all supported versions. > > I was unable to reproduce it on my machine with these settings. Tried statement timeouts 30-120s. Index build appears > to be in interruptible phase on my system. > But could you check in your environment with the following patch? > Thank you for paying attention to this! Yes, the patch works for me. The query is interrupted as expected. But I wonder, why don't you the see same? Could you please show the server log, with the following change applied and log_statement = 'all' backtrace_functions = 'ProcessInterrupts' ? --- a/src/backend/access/hash/hashsort.c +++ b/src/backend/access/hash/hashsort.c @@ -125,6 +125,7 @@ _h_indexbuild(HSpool *hspool, Relation heapRel)      uint32      hashkey = 0;  #endif +elog(LOG, "_h_indexbuild() start");      tuplesort_performsort(hspool->sortstate);      while ((itup = tuplesort_getindextuple(hspool->sortstate, true)) != NULL) @@ -151,4 +152,5 @@ _h_indexbuild(HSpool *hspool, Relation heapRel) pgstat_progress_update_param(PROGRESS_CREATEIDX_TUPLES_DONE,                                       ++tups_done);      } +elog(LOG, "_h_indexbuild() end; tups_done: %ld", tups_done);  } Best regards, Alexander --------------tzieZZ0xYrn0KOPQEy9ebWXa Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hi Pavel,

13.09.2024 17:51, Pavel Borisov wrote:


Reproduced on all supported versions.
I was unable to reproduce it on my machine with these settings. Tried statement timeouts 30-120s. Index build appears to be in interruptible phase on my system.
But could you check in your environment with the following patch?


Thank you for paying attention to this!

Yes, the patch works for me. The query is interrupted as expected.
But I wonder, why don't you the see same?

Could you please show the server log, with the following change applied and
log_statement = 'all'
backtrace_functions = 'ProcessInterrupts'
?

--- a/src/backend/access/hash/hashsort.c
+++ b/src/backend/access/hash/hashsort.c
@@ -125,6 +125,7 @@ _h_indexbuild(HSpool *hspool, Relation heapRel)
     uint32      hashkey = 0;
 #endif
 
+elog(LOG, "_h_indexbuild() start");
     tuplesort_performsort(hspool->sortstate);
 
     while ((itup = tuplesort_getindextuple(hspool->sortstate, true)) != NULL)
@@ -151,4 +152,5 @@ _h_indexbuild(HSpool *hspool, Relation heapRel)
         pgstat_progress_update_param(PROGRESS_CREATEIDX_TUPLES_DONE,
                                      ++tups_done);
     }
+elog(LOG, "_h_indexbuild() end; tups_done: %ld", tups_done);
 }

Best regards,
Alexander
--------------tzieZZ0xYrn0KOPQEy9ebWXa--