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 1pL8UB-00038N-1M for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jan 2023 20:04:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pL8UA-0005LB-18 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jan 2023 20:04:38 +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 1pL8U9-0005L2-OU for pgsql-hackers@lists.postgresql.org; Thu, 26 Jan 2023 20:04:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pL8U7-0004N9-9m for pgsql-hackers@postgresql.org; Thu, 26 Jan 2023 20:04:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30QK4Ue43165444; Thu, 26 Jan 2023 15:04:30 -0500 From: Tom Lane To: Nathan Bossart cc: Thomas Munro , "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@postgresql.org" Subject: Re: suppressing useless wakeups in logical/worker.c In-reply-to: <20230126194812.GA1702315@nathanxps13> References: <20221205173523.GA2714833@nathanxps13> <20230109174217.GA1112698@nathanxps13> <2557815.1674603908@sss.pgh.pa.us> <20230125235004.GA1327755@nathanxps13> <20230126003319.GA1507251@nathanxps13> <2878152.1674700077@sss.pgh.pa.us> <2888102.1674705840@sss.pgh.pa.us> <3126727.1674759248@sss.pgh.pa.us> <20230126194812.GA1702315@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Thu, 26 Jan 2023 11:48:12 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3165442.1674763470.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 26 Jan 2023 15:04:30 -0500 Message-ID: <3165443.1674763470@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Thu, Jan 26, 2023 at 01:54:08PM -0500, Tom Lane wrote: >> - * Both inputs must be ordinary finite timestamps (in current usage, >> - * they'll be results from GetCurrentTimestamp()). >> + * At least one input must be an ordinary finite timestamp, else the "= diff" >> + * calculation might overflow. We do support stop_time =3D=3D TIMESTA= MP_INFINITY, >> + * which will result in INT_MAX wait time. > I wonder if we should explicitly reject negative timestamps to eliminate > any chance of int64 overflow, too. Hmm. I'm disinclined to add an assumption that the epoch is in the past, but I take your point that the subtraction would overflow with TIMESTAMP_INFINITY and a negative finite timestamp. Maybe we should make use of pg_sub_s64_overflow()? BTW, I just noticed that the adjacent function TimestampDifference has a lot of callers that would be much happier using TimestampDifferenceMilliseconds. regards, tom lane