-
Notifications
You must be signed in to change notification settings - Fork 944
Fix dump/restore when chunk skipping is enabled #8211
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
Conversation
b91f94d
to
f5efdaa
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8211 +/- ##
==========================================
- Coverage 82.37% 81.98% -0.40%
==========================================
Files 256 256
Lines 48135 48129 -6
Branches 12141 12141
==========================================
- Hits 39653 39457 -196
- Misses 3615 3879 +264
+ Partials 4867 4793 -74 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f5efdaa
to
2305074
Compare
@gayyappan, @svenklemm: please review this pull request.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use NULL to represent this, since NULL means "no association with the referenced table", which is essentially what "invalid hypertable" means.
@mkindahl do you think that is a better solution than removing the FK constraint? Perhaps we should do this directly in this PR? |
IMHO; this is a better alternative since this is this is what the semantics is used for. |
2305074
to
0beed12
Compare
6e856ec
to
55817e3
Compare
@mkindahl @antekresic @fabriziomello I updated this PR to change the table schema to allow NULL values as some of you suggested. This is a bigger change than the quick fix I did first,, so I would appreciate if you could review one more time. I added some new update tests and it was a bit messy since not all tested versions support chunk skipping. Please check the update test changes to ensure I am doing sane things. |
3fd68b5
to
a22af95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch looks fine, but it would be good if we could make sure that the downgrade is truly restoring the old state.
6cc618e
to
7b060f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed, it was difficult to get it to work correctly through the downgrade with foreign keys intact, so approving the patch with the new warning since we expect downgrades to be rare.
We should probably consider removing foreign keys entirely in the catalog. After all, PostgreSQL does not use them, probably because it is hard to maintain them through catalog schema modifications.
f2475e4
to
7914fe3
Compare
The net test started to fail due to a failure or change in the remote endpoint `postman-echo.com`. Also add the telemetry to the ignore list for the sanitizer tests since it is in ignore in other tests.
The chunk skipping feature uses a "special" entry in the catalog table chunk_column_stats to indicate that chunk skipping is enabled for that column. The special entry has the chunk_id column set to 0. However, at the same time the table schema defines a foreign key on the chunk_id column where the 0 entry violates that constraint. This prevents a dump/restore from working when such an entry is present. To fix this issue, change the schema for chunk column stats to use NULL instead of 0 for "chunk_id" to indicate the special entry. Foreign keys work with such NULL entries so the foreign key can remain. Add an update test to ensure that pg_dump/pg_restore works properly.
7914fe3
to
fd474b0
Compare
Automated backport to 2.20.x not done: cherry-pick failed. Git status
|
## 2.20.3 (2025-06-11) This release contains bug fixes since the 2.20.2 release. We recommend that you upgrade at the next available opportunity. **Bugfixes** * [#8107](#8107) Adjust SkipScan cost for quals needing full scan of indexed data. * [#8211](#8211) Fixed dump and restore when chunk skipping is enabled. * [#8216](#8216) Fix for dropped quals bug in SkipScan. * [#8230](#8230) Fix for inserting into compressed data when a vectorized check is not available. * [#8236](#8236) Fixed the snapshot handling in background workers. **Thanks** * @ikaakkola for reporting that SkipScan is slow when non-index quals do not match any tuples.
The chunk skipping feature uses a "special" entry in the catalog table chunk_column_stats to indicate that chunk skipping is enabled for that column. The special entry has the chunk_id column set to 0. However, at the same time the table schema defines a foreign key on the chunk_id column where the 0 entry violates that constraint. This prevents a dump/restore from working when such an entry is present.
To fix this issue, change the schema for chunk column stats to use NULL instead of 0 for "chunk_id" to indicate the special entry. Foreign keys work with such NULL entries so the foreign key can remain.
Add an update test to ensure that pg_dump/pg_restore works properly.
Fixes: #8130
Disable-check: commit-count