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

Internal Server Error when loading Explorer tab #5723

Merged
merged 1 commit into from
Jun 1, 2023
Merged

Conversation

pdipesh02
Copy link
Contributor

@pdipesh02 pdipesh02 commented May 25, 2023

This is with reference to a weird scenarios where chunk table entry exist in timescaledb catalog but it does not exist in PG catalog. The stale entry blocks executing hypertable_size function on the hypertable.

The changes in this patch are related to improvements suggested for hypertable_size function which involves:

  1. Locking the hypertable in ACCESS SHARE mode in function hypertable_size to avoid risk of chunks being dropped by another concurrent process.
  2. Joining the hypertable and inherited chunk tables with "pg_class" to make sure that a stale table without an entry is pg_catalog is not included as part of hypertable size calculation.

NOTE: With this change calling hypertable_size function will require select privilege on the table.

Closes https://github.com/timescale/Support-Dev-Collab/issues/995
Disable-check: force-changelog-file

@CLAassistant
Copy link

CLAassistant commented May 25, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link

@nikkhils, @RafiaSabih: please review this pull request.

Powered by pull-review

sql/size_utils.sql Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Merging #5723 (ae21ee9) into main (ecc1b7b) will decrease coverage by 0.07%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #5723      +/-   ##
==========================================
- Coverage   87.85%   87.79%   -0.07%     
==========================================
  Files         234      234              
  Lines       54987    54982       -5     
  Branches    12114    12113       -1     
==========================================
- Hits        48310    48269      -41     
- Misses       4852     4855       +3     
- Partials     1825     1858      +33     

see 21 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

sql/size_utils.sql Outdated Show resolved Hide resolved
sql/size_utils.sql Outdated Show resolved Hide resolved
_timescaledb_catalog.hypertable ht
JOIN pg_class c ON relname = ht.table_name AND c.relkind = 'r'
JOIN pg_namespace n ON n.oid = c.relnamespace
AND n.nspname = schema_name_in
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
AND n.nspname = schema_name_in
AND n.nspname = ht.schema_name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@fabriziomello fabriziomello left a comment

Choose a reason for hiding this comment

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

Left just a minor suggestion but approved anyway. Thanks for working on this!

This is with reference to a weird scenarios where chunk table entry exist in
timescaledb catalog but it does not exist in PG catalog. The stale entry blocks
executing hypertable_size function on the hypertable.

The changes in this patch are related to improvements suggested for
hypertable_size function which involves:
1. Locking the hypertable in ACCESS SHARE mode in function hypertable_size to
avoid risk of chunks being dropped by another concurrent process.
2. Joining the hypertable and inherited chunk tables with "pg_class" to make
sure that a stale table without an entry is pg_catalog is not included as part
of hypertable size calculation.
3. An additional filter (schema_name) is required on pg_class to avoid
calculating size of multiple hypertables with same in different schema.

NOTE: With this change calling hypertable_size function will require select
privilege on the table.
sql/size_utils.sql Show resolved Hide resolved
@pdipesh02 pdipesh02 merged commit c507f31 into main Jun 1, 2023
42 of 43 checks passed
@pdipesh02 pdipesh02 deleted the ts_ht_size branch June 1, 2023 14:04
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.

None yet

4 participants