Skip to content
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

Fix: the 'smgropen' in the 'calculate_relation_size' function may return an incorrect 'smgrRelation' #518

Conversation

Lzjing-1997
Copy link

steps to reproduce:

postgres=# create table sa(a int) partition by range(a);
CREATE TABLE
postgres=# create unlogged table sb(b int) partition by range(b);
CREATE TABLE
postgres=# select pg_relation_size('sa'), pg_relation_size('sb');
ERROR: relpersistence mismatch: smgropen u vs SmgrRelation p

For a partitioned table, the relfilenode of its parent table is always 0 ; 'smgropen' in function 'calculate_relation_size' may get incorrect 'smgrRelation' due to 'SMgrRelationHash'.

@tristan957
Copy link
Member

I have created a team task for us to review your PR. Thanks for contributing!

github-merge-queue bot pushed a commit to neondatabase/neon that referenced this pull request Jan 24, 2025
## Problem

Parent of partitioned table has no storage, it relfilelocator is zero.
It cab be incorrectly hashed and produce wrong results.

See neondatabase/postgres#518

## Summary of changes

This problem is already addressed in pg17.
Add the same check for all other PG versions.

Postgres PRs:
neondatabase/postgres#566
neondatabase/postgres#565
neondatabase/postgres#564

Co-authored-by: Konstantin Knizhnik <[email protected]>
@ololobus
Copy link
Member

@knizhnik fixed it in neondatabase/neon#10477 in a slightly different way, so I'm closing this one. We still really appreciate your contribution, @Lzjing-1997, thank you!

@ololobus ololobus closed this Jan 31, 2025
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.

3 participants