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 1sgUTw-002u27-4f for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 19:25:28 +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 1sgUTt-0033St-Su for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 19:25:26 +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 1sgUTt-0033Sl-IV for pgsql-hackers@lists.postgresql.org; Tue, 20 Aug 2024 19:25:26 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sgUTq-000f0w-6X for pgsql-hackers@postgresql.org; Tue, 20 Aug 2024 19:25:25 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-81f86fd9305so312593839f.0 for ; Tue, 20 Aug 2024 12:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724181921; x=1724786721; darn=postgresql.org; h=content-transfer-encoding:mime-version:in-reply-to:references :thread-topic:message-id:cc:to:from:subject:date:user-agent:from:to :cc:subject:date:message-id:reply-to; bh=RkBgdSkcnLEXnjzHDS4jR7vTjp+jHlcRIF27sJpgYjY=; b=iqO1KVthyTjji4+TJ/5JHHGMvkYyUEFZnru+ZAqakQ/vnN2eNw43gg+rePEopNkndv HvztwKh50jYMcDrCeoE+diC7J0JAHgxcpPbF5yll69LXyndsNtYabz+kasJG3Or9zpyr JKtFdhh4NnSQBDy/keTr3MUusBWQa2LkUnjgEjQyAWXIm4qxIP3ALpYelcXTMzIdvHG6 tX0Sia2GaET3R0RocsZ/f9i4FSuj+n7geFhwos4KFl1lFTQPuGFnndGuVi0spYhJtlzN 7JfNJm8Lkowsx2EHj923anzinfX/G4kGAmfr18aUifGY2shb/uxMnUTpNvEI+ab7pjID 5WlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724181921; x=1724786721; h=content-transfer-encoding:mime-version:in-reply-to:references :thread-topic:message-id:cc:to:from:subject:date:user-agent :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RkBgdSkcnLEXnjzHDS4jR7vTjp+jHlcRIF27sJpgYjY=; b=nHVQBeOyzFJUQH5uJMNwumLx1B8Zg+U9ZyJtfPCVzRfhkiWci8+7SlQlWmvGRYZYSz OqGnKkKeNf4lRyuMp+xbZ/ODW3ZdLTOAEOPAU4YINGIzhjtl2jD6lAgIe9sl5xICYHSW MrQXLmkhAvjdq2eXnh/QIAnAMaCjy938roHcVgFyvj8RYyulnEYElA9waLaCfwIK1ocF x5WA1iTMsMumC2zMJlIRht16jw4hi4aQ9D9Y8/OW2+oUIDX+3yuusfdmzQbFPAAmo9Ui d0+vqFor4Yh9BkDZGkp8O81150+DeQzusd4bV51aS6cPBrAjuJv2fCArLL3jUq7B87zw HLSA== X-Forwarded-Encrypted: i=1; AJvYcCUIHXx0gysabBacR+ANJDzf2IhLfg32OSen3KY1HLxfCQOs1NkyCVnkVk74pd/Iyd3PLjVSWRG+4UUN1WLP@postgresql.org X-Gm-Message-State: AOJu0YyACfq3Wub3Z8Ppc/wXWMmttEAcOot1i20Rv6BQaAbtsPOowPLd +sYQOiqZEqfMtYBVa5fy1Wvb/gS9I8tNg7s004Z5XRveCpwGRYW+ X-Google-Smtp-Source: AGHT+IEwxJBPpr5nVYCcvE/TJQXkbr+4I51FWZOyYnCaAFbYHWZ5O5rZGDpUd5nHfchMeTHMOH/hZQ== X-Received: by 2002:a05:6e02:1c04:b0:39d:23e7:9709 with SMTP id e9e14a558f8ab-39d26d04957mr212551335ab.13.1724181921257; Tue, 20 Aug 2024 12:25:21 -0700 (PDT) Received: from [192.168.87.22] (c-73-74-200-24.hsd1.il.comcast.net. [73.74.200.24]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d2a92e36fsm35005665ab.12.2024.08.20.12.25.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Aug 2024 12:25:20 -0700 (PDT) User-Agent: Microsoft-MacOutlook/16.86.24062313 Date: Tue, 20 Aug 2024 14:25:19 -0500 Subject: Re: Restart pg_usleep when interrupted From: Sami Imseih To: Bertrand Drouvot , Nathan Bossart CC: Heikki Linnakangas , Tom Lane , Robert Haas , "pgsql-hackers@postgresql.org" Message-ID: <40F4611D-C92D-4569-8C4A-87A7DAAC4A09@gmail.com> Thread-Topic: Restart pg_usleep when interrupted References: <2b5ac681-11d5-470d-af40-89ead9a868aa@gmail.com> <90ec1618-58db-46b3-8c9b-13616ac839a7@gmail.com> In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > As it looks like we have a consensus that reducing the number of interrupts also > makes sense, I just provided a rebase version of the 1 Hz version (see [0], that > also makes clear in the doc that the new field might show slightly old values). That makes sense. However, I suspect the "1 Hz" work code will no longer be needed if CF entry 5118 [1] mentioned by Thomas [2] a few days back goes through. Maybe this extra work can be removed if [1] goes through. What do you think? With regards to CF 5118 and what it means to the current discussion, below are my thoughts. I tested with both CF 5118 [1] and the cost-delay tracking patch. With that in place, pg_usleep is able to sleep the full requested, as mentioned by Thomas [3]. This is because certain interrupts like Parallel Message and others are not signaled by SIGUSR1 any longer, but with latches. From this discussion, there is desire for a sleep function that: 1/ Sleeps for the full duration of the requested time 2/ Continues to handle important interrupts during the sleep While something like CF 5118 will take care of point #1, it will not deal with #2. Also, the v11 [4] patch does not do #2 either. So I think in the sleep loop, we need a C_F_I call. The same type of loop can also be used to call WaitForSingleObject. If CF 5118 gets committed, will still need similar loop that calls C_F_I, but the function will need to call WaitLatchUs [5]. Thoughts? -- Sami [1] https://commitfest.postgresql.org/49/5118/ [2] https://www.postgresql.org/message-id/CA%2BhUKG%2Bf-nEc_SowDLW1JMUa6Of5sCK-JZ%3Dv-KhL1xgXk83fiw%40mail.gmail.com [3] https://www.postgresql.org/message-id/CA%2BhUKGKpo3fM%3DrnfdxHqt%2BjNGh_zUNcL1ob4hMsb%3DjFfKn9Aag%40mail.gmail.com [4] https://www.postgresql.org/message-id/e3297b5e-0b33-4f45-afcd-4b00ba0b3547%40gmail.com [5] https://www.postgresql.org/message-id/CA+hUKGKVbJE59JkwnUj5XMY+-rzcTFciV9vVC7i=LUfWPds8Xw@mail.gmail.com