<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">>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></div></blockquote><div><br></div><div>In the sample output you provided, the geometry for Barisal is indeed invalid, but the isValid in the select list shows true.</div><div><br></div><div>For the record, I tried the query on PostGIS 3/GEOS 3.8, and it worked as expected - no rows returned.<br></div><div><br></div><div>If this is truly a Heisenbug [1], it's going to be very hard to debug, and even if tracked down, there's unlikely to be a simple fix.  The advice is almost always to upgrade, since upgrades contain numerous fixes (and in this case seem to definitely solve the problem).</div><div><br></div><div>If it's impossible to upgrade, you'll have to figure out a workaround.  Without knowing the use case it's impossible to recommend something.  I do note that you are pushing the limits of ST_SimplifyPreserveTopology, which seems like an odd thing to do.</div><div><br></div><div><br></div><div></div><div><br></div></div></div>