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 drop chunk hook for OSM #6067

Merged
merged 1 commit into from
Sep 19, 2023
Merged

Add drop chunk hook for OSM #6067

merged 1 commit into from
Sep 19, 2023

Conversation

gayyappan
Copy link
Contributor

Add a callback for cascading drop chunks to OSM and integrate with drop_chunks

Add tests to verify that callbacks are triggered for drop_chunks

@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Merging #6067 (c8dbb2e) into main (7d1cc93) will decrease coverage by 0.03%.
The diff coverage is 67.64%.

@@            Coverage Diff             @@
##             main    #6067      +/-   ##
==========================================
- Coverage   81.52%   81.50%   -0.03%     
==========================================
  Files         246      246              
  Lines       56714    56727      +13     
  Branches    12572    12568       -4     
==========================================
- Hits        46236    46233       -3     
+ Misses       8103     8083      -20     
- Partials     2375     2411      +36     
Files Changed Coverage Δ
src/osm_callbacks.c 60.00% <57.57%> (-40.00%) ⬇️
tsl/test/src/test_chunk_stats.c 82.05% <66.66%> (-7.61%) ⬇️
src/chunk.c 89.68% <80.00%> (-0.12%) ⬇️
src/hypertable.c 84.05% <100.00%> (ø)

... and 41 files with indirect coverage changes

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

@svenklemm svenklemm added this to the TimescaleDB 2.12 milestone Sep 13, 2023
@gayyappan gayyappan force-pushed the bugfix_2 branch 2 times, most recently from df06528 to f882c94 Compare September 14, 2023 21:28
@gayyappan gayyappan marked this pull request as ready for review September 14, 2023 21:28
@gayyappan gayyappan changed the title Add drop chunk callbacks for OSM Add drop chunk hook for OSM Sep 14, 2023
src/chunk.c Outdated
@@ -3890,6 +3889,7 @@ ts_chunk_do_drop_chunks(Hypertable *ht, int64 older_than, int64 newer_than, int3

{
uint64 num_chunks = 0;
int32 osm_chunk_id = 0;
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
int32 osm_chunk_id = 0;

src/chunk.c Outdated Show resolved Hide resolved
@gayyappan gayyappan force-pushed the bugfix_2 branch 4 times, most recently from 0db4a5b to 8b2bf1f Compare September 15, 2023 16:25
src/osm_callbacks.c Outdated Show resolved Hide resolved
@iroussos iroussos mentioned this pull request Sep 18, 2023
osm_ht_drop_chunks_hook_mock(Oid osm_chunk_oid, const char *schema_name, const char *table_name,
int64 range_start, int64 range_end)
{
elog(NOTICE, "hypertable_drop_chunks_hook (%ld %ld)", range_start, range_end);
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
elog(NOTICE, "hypertable_drop_chunks_hook (%ld %ld)", range_start, range_end);
elog(NOTICE, "hypertable_drop_chunks_hook (" INT64_FORMAT " " INT64_FORMAT ")", range_start, range_end);

Comment on lines 63 to 68
for (int i = 1; i < 2; i++)
{
char *chunk_name;
chunk_name = psprintf("%s", "_timescaledb_internal.dummy");
ret = lappend(ret, chunk_name);
}
Copy link
Member

@svenklemm svenklemm Sep 19, 2023

Choose a reason for hiding this comment

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

what is the purpose of this for loop?

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.

int64 range_start = ts_internal_to_time_int64(newer_than, dim->fd.column_type);
int64 range_end = ts_internal_to_time_int64(older_than, dim->fd.column_type);
Chunk *osm_chunk = ts_chunk_get_by_id(osm_chunk_id, true);
List *osm_dropped_names = osm_drop_chunks_hook(osm_chunk->table_id,
Copy link
Member

Choose a reason for hiding this comment

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

Since those are osm-internal objects it makes no sense to return them to timescaledb.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the drop_chunks api prints the names of the dropped chunks today.
I think we need to make the call on the OSM side whether these values should be printed or not when drop_chunks is invoked.
So far, we have been consistent with the behavior across APIs.
I don't want to change the hook definition in case we decide that drop_chunks should also behave consistently.

@gayyappan gayyappan force-pushed the bugfix_2 branch 2 times, most recently from b6fb493 to 644b58b Compare September 19, 2023 17:45
Introduce version number for OsmCallbacks struct

Add a callback for cascading drop chunks to OSM and
integrate with drop_chunks

Add backward compatibility for OsmCallbacks
@gayyappan gayyappan merged commit 6e5d687 into timescale:main Sep 19, 2023
34 of 35 checks passed
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.

3 participants