Skip to content

Conversation

@manaldush
Copy link
Contributor

@manaldush manaldush commented Oct 31, 2025

Fixes #8235

PG18 and PG latest minors ignore temporary relations in RelidByRelfilenumber (RelidByRelfilenode in PG15)
Relevant PG commit:
postgres/postgres@86831952

Here we are keeping temp reloids instead of getting it with RelidByRelfilenumber, for example, in some cases, we can directly get reloid from relations, in other cases we keep it in some structures.

Note: there is still an outstanding issue with columnar temp tables in concurrent sessions, that will be fixed in PR #8252

Alternative PR to #8303
Comparing with #8303, this approach avoids copy-paste of PG vanilla codebase

Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

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

Currently evaluating this solution.

@manaldush UPDATE: after taking advice from my colleague @colm-mchugh as well, we decided this approach is better compared to #8303 for two reasons:

  1. it avoids an extra scan of pg_class for temp tables.
  2. It doesn't revert behavior that PG identified as broken, like #8303 does.

We also need comments for ColumnarRelationId and RelationPrecomputeOid_compat. Thanks for the PR.

#define RelationPhysicalIdentifierBackend_compat(a) (a->smgr_rnode.node)
typedef RelFileNode RelFileLocator;
typedef Oid RelFileNumber;
#define RelidByRelfilenumber(a, b) RelidByRelfilenode(a, b)
Copy link
Member

Choose a reason for hiding this comment

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

Should keep this as it's needed for PG15 support.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


#define RelationPhysicalIdentifier_compat(a) ((a)->rd_locator)
#define RelationTablespace_compat(a) (a.spcOid)
#define RelationPrecomputeOid_compat(a) (RelationUsesLocalBuffers(a) ? RelationGetRelid( \
Copy link
Member

Choose a reason for hiding this comment

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

This should be defined in columnar.h because all PG versions need it (we use pg_version_compat.h file for functions that need compatibility changes between different PG versions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed and renamed according with #8309 (comment)

TupleDesc tupleDescriptor;
FmgrInfo **comparisonFunctionArray;
RelFileLocator relfilelocator;
Oid temp_relid; /* We can't rely on RelidByRelfilenumber for temp tables anymore.*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Oid temp_relid; /* We can't rely on RelidByRelfilenumber for temp tables anymore.*/
Oid temp_relid; /* We can't rely on RelidByRelfilenumber for temp tables since PG18 */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see change in RelidByRelfilenumber in all version since PG13(be aware till PG16 RelidByRelfilenumber = RelidByRelfilenumber), so fixed with since PG13. If you have some doubts about this change, please notify me, I will fix it


#define RelationPhysicalIdentifier_compat(a) ((a)->rd_locator)
#define RelationTablespace_compat(a) (a.spcOid)
#define RelationPrecomputeOid_compat(a) (RelationUsesLocalBuffers(a) ? RelationGetRelid( \
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#define RelationPrecomputeOid_compat(a) (RelationUsesLocalBuffers(a) ? RelationGetRelid( \
#define RelationPrecomputeOid(a) (RelationUsesLocalBuffers(a) ? RelationGetRelid( \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed and moved to columnar.h according to #8309 (comment)

@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_beta_confs branch from 15ecb4b to 5565920 Compare November 5, 2025 18:45
@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.18%. Comparing base (188c182) to head (163bae4).
⚠️ Report is 20 commits behind head on m3hm3t/pg18_beta_confs.

❌ Your project check has failed because the head coverage (62.18%) is below the target coverage (87.50%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (188c182) and HEAD (163bae4). Click for more details.

HEAD has 75 uploads less than BASE
Flag BASE (188c182) HEAD (163bae4)
17_regress_check-pytest 1 0
15_regress_check-columnar-isolation 1 0
16_regress_check-follower-cluster 1 0
15_citus_upgrade 1 0
16_regress_check-columnar-isolation 1 0
17_regress_check-follower-cluster 1 0
15_17_upgrade 1 0
15_regress_check-follower-cluster 1 0
17_regress_check-columnar-isolation 1 0
17_regress_check-add-backup-node 1 0
15_regress_check-enterprise-isolation-logicalrep-2 1 0
17_regress_check-enterprise-isolation-logicalrep-3 1 0
16_regress_check-add-backup-node 1 0
15_16_upgrade 1 0
16_regress_check-split 1 0
17_regress_check-query-generator 1 0
15_regress_check-add-backup-node 1 0
16_17_upgrade 1 0
16_regress_check-enterprise-isolation-logicalrep-3 1 0
15_regress_check-enterprise-isolation-logicalrep-3 1 0
17_regress_check-enterprise-isolation-logicalrep-2 1 0
16_regress_check-enterprise-isolation-logicalrep-2 1 0
16_regress_check-query-generator 1 0
15_regress_check-query-generator 1 0
15_regress_check-columnar 1 0
15_regress_check-split 1 0
17_regress_check-enterprise-failure 1 0
16_regress_check-columnar 1 0
16_regress_check-enterprise-failure 1 0
17_regress_check-columnar 1 0
15_regress_check-vanilla 1 0
15_regress_check-failure 1 0
16_regress_check-failure 1 0
15_regress_check-enterprise-failure 1 0
17_regress_check-enterprise 1 0
15_regress_check-enterprise 1 0
17_regress_check-split 1 0
16_regress_check-vanilla 1 0
16_regress_check-enterprise 1 0
17_regress_check-vanilla 1 0
15_regress_check-enterprise-isolation 1 0
16_regress_check-enterprise-isolation 1 0
17_regress_check-enterprise-isolation 1 0
17_regress_check-enterprise-isolation-logicalrep-1 1 0
16_regress_check-enterprise-isolation-logicalrep-1 1 0
17_regress_check-failure 1 0
17_regress_check-multi-mx 1 0
16_regress_check-multi-mx 1 0
15_regress_check-enterprise-isolation-logicalrep-1 1 0
15_regress_check-multi-mx 1 0
17_cdc_installcheck 1 0
16_citus_upgrade 1 0
15_regress_check-pytest 1 0
16_regress_check-pytest 1 0
15_cdc_installcheck 1 0
16_regress_check-multi 1 0
15_arbitrary_configs_3 1 0
16_arbitrary_configs_3 1 0
16_arbitrary_configs_5 1 0
17_arbitrary_configs_2 1 0
17_arbitrary_configs_5 1 0
15_regress_check-multi 1 0
17_regress_check-multi 1 0
15_regress_check-multi-1 1 0
17_regress_check-multi-1 1 0
16_arbitrary_configs_0 1 0
16_regress_check-multi-1 1 0
16_arbitrary_configs_2 1 0
17_arbitrary_configs_3 1 0
17_arbitrary_configs_4 1 0
15_arbitrary_configs_5 1 0
15_arbitrary_configs_1 1 0
17_arbitrary_configs_1 1 0
16_cdc_installcheck 1 0
16_arbitrary_configs_1 1 0
Additional details and impacted files
@@                     Coverage Diff                     @@
##           m3hm3t/pg18_beta_confs    #8309       +/-   ##
===========================================================
- Coverage                   88.96%   62.18%   -26.78%     
===========================================================
  Files                         287      287               
  Lines                       63134    62956      -178     
  Branches                     7941     7895       -46     
===========================================================
- Hits                        56165    39148    -17017     
- Misses                       4660    20826    +16166     
- Partials                     2309     2982      +673     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* to get correct relid value.
*
* Now it is basically used for temp rels, because since PGXX RelidByRelfilenumber
* Now it is basically used for temp rels, because since PG13 RelidByRelfilenumber
Copy link
Member

@naisila naisila Nov 6, 2025

Choose a reason for hiding this comment

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

Might be a bit misleading since it was a backport to PG13. Lets say sth like "since PG18 (it was backpatched through PG13)"
Same comment for columnar.h file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

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

Also citusdata:m3hm3t/pg18_beta_confs has been force pushed so could you update the PR accordingly?

EDIT: @manaldush in fact we use citusdata:m3hm3t/pg18_beta_confs for sanity checks only, and we merge directly to main branch, so it would be great if you can update the base branch to citusdata:main and include ONLY your commits.

After PG vanilla commit ab874faaa1f, RelidByRelfilenumber logic
was changed, now for temp objects its return O oid. For such
cases we can use alternative approach with keeping temp relations
oids directly.
@manaldush manaldush force-pushed the m3hm3t/pg18_beta_confs_8235 branch from 28af426 to cbf097f Compare November 6, 2025 14:15
@manaldush
Copy link
Contributor Author

Also citusdata:m3hm3t/pg18_beta_confs has been force pushed so could you update the PR accordingly?

EDIT: @manaldush in fact we use citusdata:m3hm3t/pg18_beta_confs for sanity checks only, and we merge directly to main branch, so it would be great if you can update the base branch to citusdata:main and include ONLY your commits.

done, now branch m3hm3t/pg18_beta_confs_8235 branched from main.

@naisila naisila changed the base branch from m3hm3t/pg18_beta_confs to main November 6, 2025 20:13
Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@naisila naisila merged commit daa69be into citusdata:main Nov 6, 2025
145 of 158 checks passed
manaldush added a commit to manaldush/citus that referenced this pull request Nov 7, 2025
Backporting citusdata#8235

PG18 and PG latest minors ignore temporary relations in
`RelidByRelfilenumber` (`RelidByRelfilenode` in PG15)
Relevant PG commit:
postgres/postgres@86831952

Here we are keeping temp reloids instead of getting it with
RelidByRelfilenumber, for example, in some cases, we can directly get
reloid from relations, in other cases we keep it in some structures.

Note: there is still an outstanding issue with columnar temp tables in
concurrent sessions, that will be fixed in PR
citusdata#8252
manaldush added a commit to manaldush/citus that referenced this pull request Nov 7, 2025
Backporting citusdata#8235

PG18 and PG latest minors ignore temporary relations in
`RelidByRelfilenumber` (`RelidByRelfilenode` in PG15)
Relevant PG commit:
postgres/postgres@86831952

Here we are keeping temp reloids instead of getting it with
RelidByRelfilenumber, for example, in some cases, we can directly get
reloid from relations, in other cases we keep it in some structures.

Note: there is still an outstanding issue with columnar temp tables in
concurrent sessions, that will be fixed in PR
citusdata#8252

(cherry picked from commit daa69be)
manaldush added a commit to manaldush/citus that referenced this pull request Nov 7, 2025
Backporting citusdata#8235

PG18 and PG latest minors ignore temporary relations in
`RelidByRelfilenumber` (`RelidByRelfilenode` in PG15)
Relevant PG commit:
postgres/postgres@86831952

Here we are keeping temp reloids instead of getting it with
RelidByRelfilenumber, for example, in some cases, we can directly get
reloid from relations, in other cases we keep it in some structures.

Note: there is still an outstanding issue with columnar temp tables in
concurrent sessions, that will be fixed in PR
citusdata#8252

(cherry picked from commit daa69be)
manaldush added a commit to manaldush/citus that referenced this pull request Nov 7, 2025
Backporting citusdata#8235

PG18 and PG latest minors ignore temporary relations in
`RelidByRelfilenumber` (`RelidByRelfilenode` in PG15)
Relevant PG commit:
postgres/postgres@86831952

Here we are keeping temp reloids instead of getting it with
RelidByRelfilenumber, for example, in some cases, we can directly get
reloid from relations, in other cases we keep it in some structures.

Note: there is still an outstanding issue with columnar temp tables in
concurrent sessions, that will be fixed in PR
citusdata#8252

(cherry picked from commit daa69be)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PG18 - columnar temp tables cannot be accessed "could not open relation with oid 0"

2 participants