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

Modify dimension slice catalog update API #6838

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

antekresic
Copy link
Contributor

@antekresic antekresic commented Apr 18, 2024

Use the same logic as PR 6773 while updating dimension slice catalog tuples. PR 6773 addresses chunk catalog updates. We first lock the tuple and then modify the values and update the locked tuple. Replace ts_dimension_slice_update_by_id with field specific APIs and use dimension_slice_update_catalog_tuple calls consistently.

Disable-check: force-changelog-file

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 79.54545% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 81.75%. Comparing base (59f50f2) to head (567bc0f).
Report is 192 commits behind head on main.

Files Patch % Lines
src/dimension_slice.c 79.31% 7 Missing and 11 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6838      +/-   ##
==========================================
+ Coverage   80.06%   81.75%   +1.68%     
==========================================
  Files         190      199       +9     
  Lines       37181    37005     -176     
  Branches     9450     9669     +219     
==========================================
+ Hits        29770    30253     +483     
+ Misses       2997     2866     -131     
+ Partials     4414     3886     -528     

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

@antekresic antekresic force-pushed the slice-update branch 3 times, most recently from 3e41345 to 12e7400 Compare May 14, 2024 12:27
@antekresic antekresic marked this pull request as ready for review May 14, 2024 12:29
src/dimension_slice.h Outdated Show resolved Hide resolved
src/dimension_slice.c Show resolved Hide resolved
* call dimension_slice_delete_catalog_tuple to complete the delete.
* This ensures correct tuple locking and tuple deletes in the presence of
* concurrent transactions. Failure to follow this results in catalog corruption
*/
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a check for this sequence e.g. with coccinelle?

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'm not sure tbh. There is clearly more places in the codebase which don't update/delete catalog tuples this way so it might be premature at this point.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to check this sequence via coccinelle. Not blocking this PR, but as a follow up safety check. I believe we have fixed all the known places that violate this sequence with this PR.

@antekresic antekresic force-pushed the slice-update branch 2 times, most recently from 4148eda to a994510 Compare May 29, 2024 05:36
Copy link
Contributor

@gayyappan gayyappan left a comment

Choose a reason for hiding this comment

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

Changes look good.
1 open question

* call dimension_slice_delete_catalog_tuple to complete the delete.
* This ensures correct tuple locking and tuple deletes in the presence of
* concurrent transactions. Failure to follow this results in catalog corruption
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to check this sequence via coccinelle. Not blocking this PR, but as a follow up safety check. I believe we have fixed all the known places that violate this sequence with this PR.

@@ -638,23 +799,14 @@ ts_dimension_slice_delete_by_dimension_id(int32 dimension_id, bool delete_constr
int
ts_dimension_slice_delete_by_id(int32 dimension_slice_id, bool delete_constraints)
{
ScanKeyData scankey[1];
FormData_dimension_slice form;
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we also have to modify ts_dimension_slice_delete_by_dimension_id function (line 777) to follow the same pattern?

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've added tuple locking to ts_dimension_slice_delete_by_dimension_id and check for lock result so effectively we get the same behavior as with the custom workflow. I don't want to re-implement the scanner for deletes since they are not at issue here.

Refactor was mostly directed at updates due to concurrent operations creating phantom updates.

Use the same logic as PR 6773 while updating dimension slice catalog
tuples. PR 6773 addresses chunk catalog updates. We first lock the
tuple and then modify the values and update the locked tuple. Replace
ts_dimension_slice_update_by_id with field specific APIs and use
dimension_slice_update_catalog_tuple calls consistently.
@antekresic antekresic merged commit 7694c4a into timescale:main Jun 3, 2024
36 of 37 checks passed
@akuzm akuzm mentioned this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants