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 1nLBGl-0008Gb-V5 for pgsql-general@arkaria.postgresql.org; Fri, 18 Feb 2022 21:58:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLBGk-0002NX-2K for pgsql-general@arkaria.postgresql.org; Fri, 18 Feb 2022 21:58:26 +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 1nLBGj-0002NO-OK for pgsql-general@lists.postgresql.org; Fri, 18 Feb 2022 21:58:25 +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 1nLBGd-0002D5-0B for pgsql-general@lists.postgresql.org; Fri, 18 Feb 2022 21:58:25 +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 21ILw6l54159420; Fri, 18 Feb 2022 16:58:06 -0500 From: Tom Lane To: "Peter J. Holzer" cc: pgsql-general@lists.postgresql.org, Carsten Klein Subject: Re: Strange results when casting string to double In-reply-to: <20220218214249.su6x5hi6ixauggku@hjp.at> References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com> <4592fac1-05b2-f775-3332-c5a7d4c65b9d@datagis.com> <3950189.1645198347@sss.pgh.pa.us> <6593fee3-477b-6069-f91e-79f91075808f@datagis.com> <20220218214249.su6x5hi6ixauggku@hjp.at> Comments: In-reply-to "Peter J. Holzer" message dated "Fri, 18 Feb 2022 22:42:49 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4159418.1645221486.1@sss.pgh.pa.us> Date: Fri, 18 Feb 2022 16:58:06 -0500 Message-ID: <4159419.1645221486@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Peter J. Holzer" writes: > Another idea: It could be the case that something (maybe a bug in > postgres, maybe an extension, maybe even a random bit flip in memory) > changed the FP rounding mode within the postgres process, which would > affect all FP computations until the rounding mode is reset. That would > have to have happened in the master to affect the worker processes as > consistently as you are seeing. I don't know if it is even possible for > a non-standard rounding mode to persist for any length of time, but if > it is it would certainly account for weird rounding errors. Hmm, that is a pretty interesting theory. On a RHEL8 box, I find that fesetround(FE_DOWNWARD) causes strtod("1.56", NULL) to return 1.55999999999999983124 rather than the usual 1.56000000000000005329 which seems to square with Carsten's symptom. Postgres itself contains no fesetround calls, but if you want to believe a random bit flip changed that mode, maybe that'd account for it. It'd certainly be interesting to find out whether the problem persists after a postmaster restart. [ wanders away wondering if the troublesome machine has ECC memory ... ] regards, tom lane