Skip to content

Use smgrexists() instead of access() to enforce uniqueness of generated relfilenumber #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

knizhnik
Copy link

@knizhnik knizhnik commented Jun 7, 2024

Postgres is using access() function in GetNewRelFileNumber to check if assigned relfilenumber is not used for any other relation. This check will not work in Neon, because we do not have all files in local storage.
Use smgrexists() instead which will check at page server if such relfilenode is used.

@knizhnik knizhnik force-pushed the get_relfilenum_fix_v16 branch from cf28299 to 9f6daf0 Compare June 11, 2024 13:22
Copy link
Member

@tristan957 tristan957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@knizhnik knizhnik force-pushed the get_relfilenum_fix_v16 branch from 9f6daf0 to b39f316 Compare July 3, 2024 14:13
@knizhnik knizhnik merged commit 5377f5e into REL_16_STABLE_neon Aug 4, 2024
@knizhnik knizhnik deleted the get_relfilenum_fix_v16 branch August 4, 2024 12:47
poojanilangekar pushed a commit to umd-dslam/sunstorm-postgres that referenced this pull request Aug 26, 2024
…epers (neondatabase#439).

It is intended to solve the following problems:

a) Chicken-or-the-egg one: compute postgres needs data directory
   with non-rel files that are downloaded from pageserver by calling
   basebackup@LSN. This LSN is not arbitrary, it must include all
   previously committed transactions and defined through consensus
   voting, which happens... in walproposer, a part of compute node.

b) Just warranting such LSN is not enough, we must also actually commit
   it and make sure there is a safekeeper who knows this LSN is
   committed so WAL before it can be streamed to pageserver -- otherwise
   basebackup will hang waiting for WAL. Advancing commit_lsn without
   playing consensus game is impossible, so speculative 'let's just poll
   safekeepers, learn start LSN of future epoch and run basebackup'
   won't work.

Currently --sync-safekeepers is considered completed when 1) at least majority
of safekeepers and 2) *all* safekeepers with live connection to walproposer
switch to new epoch and advance commit_lsn allowing basebackup to proceed. 2)
limits availablity, but that's because currently we don't have a mechanism
defining which safekeeper should stream WAL into pageserver.
lubennikovaav pushed a commit that referenced this pull request May 13, 2025
…epers (#439).

It is intended to solve the following problems:

a) Chicken-or-the-egg one: compute postgres needs data directory
   with non-rel files that are downloaded from pageserver by calling
   basebackup@LSN. This LSN is not arbitrary, it must include all
   previously committed transactions and defined through consensus
   voting, which happens... in walproposer, a part of compute node.

b) Just warranting such LSN is not enough, we must also actually commit
   it and make sure there is a safekeeper who knows this LSN is
   committed so WAL before it can be streamed to pageserver -- otherwise
   basebackup will hang waiting for WAL. Advancing commit_lsn without
   playing consensus game is impossible, so speculative 'let's just poll
   safekeepers, learn start LSN of future epoch and run basebackup'
   won't work.

Currently --sync-safekeepers is considered completed when 1) at least majority
of safekeepers and 2) *all* safekeepers with live connection to walproposer
switch to new epoch and advance commit_lsn allowing basebackup to proceed. 2)
limits availablity, but that's because currently we don't have a mechanism
defining which safekeeper should stream WAL into pageserver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants