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

Add workaround for pg_depend bug in PG < 15.4 #7508

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

erimatnor
Copy link
Contributor

@erimatnor erimatnor commented Dec 2, 2024

PostgreSQL versions prior to 15.4 didn't properly update object dependencies when setting a new access method on a table. The fix for the bug is found in this commit:

postgres/postgres@97d8910

The hypercore_create test failed on buggy PG versions (e.g., 15.0) due to wrong contents of pg_depend showing up in test output when converting a table from Hypercore TAM back to regular heap.

This change adds a workaround that updates pg_depend with the correct information when compiling against PG versions that suffer from the bug.

Disable-check: force-changelog-file
Disable-check: approval-count

PostgreSQL versions prior to 15.4 didn't properly update object
dependencies when setting a new access method on a table. The fix for
the bug is found in this commit:

postgres/postgres@97d8910

The `hypercore_create` test failed on buggy PG versions (e.g., 15.0)
due to wrong contents of pg_depend showing up in test output when
converting a table from Hypercore TAM back to regular heap.

This change adds a workaround that updates pg_depend with the correct
information when compiling against PG versions that suffer from the
bug.
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.14%. Comparing base (59f50f2) to head (b0e3602).
Report is 637 commits behind head on main.

Files with missing lines Patch % Lines
tsl/src/compression/api.c 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7508      +/-   ##
==========================================
+ Coverage   80.06%   82.14%   +2.07%     
==========================================
  Files         190      230      +40     
  Lines       37181    43190    +6009     
  Branches     9450    10868    +1418     
==========================================
+ Hits        29770    35478    +5708     
- Misses       2997     3387     +390     
+ Partials     4414     4325      -89     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mkindahl mkindahl left a comment

Choose a reason for hiding this comment

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

Nice catch!

Comment on lines +790 to +800
#if (PG_VERSION_NUM < 150004)
/* Fix for PostgreSQL bug where pg_depend was not updated to reflect the
* new dependency between AM and relation. See related PG fix here:
* https://github.com/postgres/postgres/commit/97d89101045fac8cb36f4ef6c08526ea0841a596 */
if (changeDependencyFor(RelationRelationId, relid, AccessMethodRelationId, amoid, new_amoid) !=
1)
elog(ERROR,
"could not change access method dependency for relation \"%s.%s\"",
get_namespace_name(get_rel_namespace(relid)),
get_rel_name(relid));
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this was reported in 16beta1 it seems like it should be fixed in all GA versions of PostgreSQL after 16.0, so double-checking that it is indeed the case and this is the result. You might want to add a comment to why this is not necessary to check for later versions, but IMHO this is entirely optional since it was fixed before the GA release of the other versions.

mats@fury:~/repos/postgres$ git log --grep "Fix pg_depend entry" --oneline
97d8910104 Fix pg_depend entry to AMs after ALTER TABLE .. SET ACCESS METHOD
mats@fury:~/repos/postgres$ git tag --contains 97d8910104
REL_16_0
REL_16_1
REL_16_2
REL_16_3
REL_16_4
REL_16_5
REL_16_6
REL_16_BETA3
REL_16_RC1
REL_17_0
REL_17_1
REL_17_2
REL_17_BETA1
REL_17_BETA2
REL_17_BETA3
REL_17_RC1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for double-checking.

@erimatnor erimatnor merged commit 8d29760 into timescale:main Dec 3, 2024
54 of 59 checks passed
@erimatnor erimatnor deleted the workaround-pg-dependency-bug branch December 3, 2024 09:08
@timescale-automation
Copy link

Automated backport to 2.17.x not done: cherry-pick failed.

Git status

HEAD detached at origin/2.17.x
You are currently cherry-picking commit 8d2976072.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tsl/src/compression/api.c

no changes added to commit (use "git add" and/or "git commit -a")

Job log

@timescale-automation timescale-automation added the auto-backport-not-done Automated backport of this PR has failed non-retriably (e.g. conflicts) label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport-not-done Automated backport of this PR has failed non-retriably (e.g. conflicts) bug hypercore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants