From: Carsten Klein <c.klein@datagis.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Strange results when casting string to double
Date: Wed, 16 Feb 2022 22:02:02 +0100
Message-ID: <8d9290c7-684d-c445-830b-b738ce558d19@datagis.com> (raw)
In-Reply-To: <CAKFQuwbt-F3BQHfhKNFt3NLMzjHsDSawkvPn7A-ezJzJA3aELg@mail.gmail.com>
References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com>
<d07e34aa-0c42-f857-39d8-265d63998417@aklaver.com>
<a89c2e30-3775-799b-37f0-bd07d3b7c55f@datagis.com>
<CAKFQuwbt-F3BQHfhKNFt3NLMzjHsDSawkvPn7A-ezJzJA3aELg@mail.gmail.com>
On Wed, Feb 16, 2022 at 08:11 PM David G. Johnston wrote:
> You said they are more or less the same. Problems like these tend to
> hide in the "less" portion of the inequality.
On of the virtualized servers was created as a clone of the other one
(using VMware to clone the VM). So, basically, these are very equal. Of
course, they diverged over time.
Focusing on PostgreSQL, here are the differences of postgresql.conf,
comparing testing system and production system:
< work_mem = 8MB # min 64kB
---
> work_mem = 4MB # min 64kB
417c417
< #log_statement = 'all' # none, ddl, mod, all
---
> #log_statement = 'none' # none, ddl, mod, all
Both PostgreSQL server have the same roles and users, that same
extensions installed and no preloaded libraries.
> Given that this isn't working as expected it doesn't make for a great
> testing system. Install and initdb 14.2 on this machine and let's see
> what PostgreSQL produces.
The testing system runs since 2015. I don't know whether the problem was
present from the beginning. But I don't think so, as we also have
"correct" double values in that database. Now, since "binary equality"
of the double precision values is a new requirement, we started to
notice, that (at least not) newly added (UPDATEd) values, e. g. 1.56 are
not binary equal to already present values:
Table abc, column xyz: currently (before) 1.56
UPDATE abc SET xyz = 1.56;
Table abc, column xyz: after 1.559999999
We have a trigger, that monitors such updates and it reports a changed
value, which is not correct. The problem is, that the assignment
SET xyz = 1.56
actually means
SET xyz = 1.559999999
since getting a double value from the string 1.56 yields 1.559999999.
Yes, moving to the latest PostgreSQL version might fix that error.
However, this is a customer's testing system. Actually, it is intended
to be reinstalled with Ubuntu 22.04 LTS which brings PostgreSQL 14. But
prior to that, we need to complete a project on the testing system that
requires that "binary equality" of double values.
> What is the precise version of libc that is installed for one. Exact
> ESX releases too.
Both VM servers run on
ESXi 6 (correct behavior)
ESXi 6.5 (misbehaving)
All machines use libc version 2.19 (libc-2.19.so).
> This isn't really all that interesting a report for the project if it
> only exists in one ancient system that cannot be experimented with.
> Maybe it's a faulty register on that machine's CPU. There is more
> double-checking and comparing that can be done here but it seems
> unlikely to be productive. It is more plausible that the snowflake
> machine in question just has issues and needs to be retired. Installing
> a newer version of PostgreSQL on it before junking it is about the right
> amount of experimental effort.
I just wanted to ask whether someone knows something about this or has
ever heard about such a behavior. You say, the snowflake machine has
issues... I don't believe in hardware issues, since it runs in VMware
and likely on many different CPUs. Isn't it more than unlikely that such
a constantly occurring error is caused by one faulty CPU (among that
many CPUs an ESX server typically has)?
And, keep in mind that strtod function works as expected from a simply C
testing program. I guess that the parsed double's value gets modified
somewhere in PostgreSQL after strtod was called. However, I do not yet
see where and why. I was hoping that someone of you could help.
Carsten
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: c.klein@datagis.com, david.g.johnston@gmail.com, adrian.klaver@aklaver.com
Subject: Re: Strange results when casting string to double
In-Reply-To: <8d9290c7-684d-c445-830b-b738ce558d19@datagis.com>
References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com> <d07e34aa-0c42-f857-39d8-265d63998417@aklaver.com> <a89c2e30-3775-799b-37f0-bd07d3b7c55f@datagis.com> <CAKFQuwbt-F3BQHfhKNFt3NLMzjHsDSawkvPn7A-ezJzJA3aELg@mail.gmail.com> <8d9290c7-684d-c445-830b-b738ce558d19@datagis.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox