neondatabase / neon

Neon: Serverless Postgres. We separated storage and compute to offer autoscaling, code-like database branching, and scale to zero.
https://neon.tech
Apache License 2.0
13.15k stars 368 forks source link

RelFileNumber reuse protection is broken #7981

Open hlinnaka opened 2 weeks ago

hlinnaka commented 2 weeks ago

GetNewRelFileNumber() checks the filesystem directly with access(), to see if a relfilenumber is already in use. That doesn't work with Neon storage, because the relations don't have files in local filesystem. As a result, after oid wraparound, a new relation might be assigned a relfilenumber that's already in use by another relation, with catastrophic consequences.

kelvich commented 2 weeks ago

@hlinnaka is there any related slack thread / error message? Or you just spotted it?

hlinnaka commented 2 weeks ago

No thread or error message.

We were chatting with Konstantin about something different, when I remembered that that code exists. I then went to see if we had did something to make it work in neon, and turns out we had not.

kelvich commented 1 day ago

@tristan957 can you please take a look