<div dir="ltr"><div style="font-size:small" class="gmail_default">>><br>>> >You could capture the full output from a few runs and provide that (with<br>>> >geometry as WKB). That might allow seeing if the discrepancy is real and<br>>> >why it is happening.<br>>><br>><br>>In the sample output you provided, the geometry for Barisal is indeed<br>>invalid, but the isValid in the select list shows true.<br>><br>>For the record, I tried the query on PostGIS 3/GEOS 3.8, and it worked as<br>>expected - no rows returned.<br>><br>>If this is truly a Heisenbug [1], it's going to be very hard to debug, and<br>>even if tracked down, there's unlikely to be a simple fix.  The advice is<br>>almost always to upgrade, since upgrades contain numerous fixes (and in<br>>this case seem to definitely solve the problem).<br>><br>>If it's impossible to upgrade, you'll have to figure out a workaround.<br>>Without knowing the use case it's impossible to recommend something.  I do<br>>note that you are pushing the limits of ST_SimplifyPreserveTopology, which<br>>seems like an odd thing to do.</div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default">Just installed latest postgres12 with latest postgis.</div><div style="font-size:small" class="gmail_default">"POSTGIS="3.0.1 3.0.1" [EXTENSION] PGSQL="120" GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 5.2.0, September 15th, 2018" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.4.3 (Internal)""<br>"PostgreSQL 12.2, compiled by Visual C++ build 1914, 64-bit"</div><div style="font-size:small" class="gmail_default">On windows 7 64bit.</div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default">Still having the same issues though not 100% of the time, more like 10%</div><div style="font-size:small" class="gmail_default">And also giving "t" for ST_isvalid(simplifiedgeo2) despite the WHERE NOT ST_isvalid(simplifiedgeo2)</div></div>