Subject: inconsistency between the VM page visibility status and the visibility status of the page

From: "yanhui.xiong"<[email-masked]>
Date: Thu, 20 Jul 2023 14:44:49 +0800

Hi,
i had a issue here, When executing a SELECT statement using an index-only scan, i got a wrong row number because there may be an inconsistency between the VM page visibility status and the visibility status of the page,the VM bit is set and page-level is clear

i read the code and note that there has a chance to happen like this,but how it happens?
the code do clear the page-level visibility and vm bit at the same time, i don not understand how it happens

---

From: Tomas Vondra <[email-masked]>
Date: Thu, 20 Jul 2023 12:16:26 +0200

On 7/20/23 08:44, yanhui.xiong wrote:
> Hi,
> 
> i had a issue here, When executing a SELECT statement using an
> index-only scan, i got a wrong row number because there may be an
> inconsistency between the VM page visibility status and the visibility
> status of the page,the VM bit is set and page-level is clear
> 
> 

Well, by only looking at the code you're assuming two things:

1) the code is correct

2) the environment is perfect

Either (or both) of these assumptions may be wrong. There certainly
could be some subtle bug in the visibility map code, who knows. Or maybe
this is due to some sort of data corruption outside postgres.

It's impossible to answer without you digging much deeper and providing
much more information. What's the environment? What hardware? What PG
version? How long is it running? Any crashes? Any other cases of similar
issues? What does the page look like in pageinspect?

regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company