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

Fix alter_job not updating new job fields #2404

Merged
merged 1 commit into from Sep 18, 2020

Conversation

svenklemm
Copy link
Member

@svenklemm svenklemm commented Sep 16, 2020

Fix bgw_job_tuple_update_by_id to also update scheduled and config
field of bgw_job.

Fixes #2402

@svenklemm svenklemm requested a review from a team as a code owner September 16, 2020 01:38
@svenklemm svenklemm requested review from pmwkaa, k-rus and gayyappan and removed request for a team September 16, 2020 01:38
@codecov
Copy link

codecov bot commented Sep 16, 2020

Codecov Report

Merging #2404 into master will increase coverage by 0.13%.
The diff coverage is 96.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2404      +/-   ##
==========================================
+ Coverage   89.95%   90.09%   +0.13%     
==========================================
  Files         213      213              
  Lines       34354    34323      -31     
==========================================
+ Hits        30904    30923      +19     
+ Misses       3450     3400      -50     
Impacted Files Coverage Δ
src/bgw/job.c 95.07% <96.96%> (+0.28%) ⬆️
src/loader/bgw_message_queue.c 87.09% <0.00%> (-0.65%) ⬇️
tsl/src/bgw_policy/job_api.c 93.10% <0.00%> (+1.14%) ⬆️
src/import/planner.c 70.30% <0.00%> (+11.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17cc6f6...c8c60b5. Read the comment docs.

@svenklemm svenklemm added this to the 2.0.0 milestone Sep 16, 2020
@svenklemm svenklemm added bgw The background worker subsystem, including the scheduler bug labels Sep 16, 2020
Copy link
Contributor

@k-rus k-rus left a comment

Choose a reason for hiding this comment

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

LGTM, few nit comments
Can you add commit message body and clarify, which new job fields are fixed? Isn't just the config in JSON?
Can you add link to the issue being fixed?
Variable name mod_tuple is not easy to follow, so I suggest to fix it back to new_tuple, which is commonly used through the code.
It will be an advantage of having new line separating declaration block and the assert.

@@ -907,21 +907,25 @@
BgwJob *updated_job = (BgwJob *) data;
bool should_free;
HeapTuple tuple = ts_scanner_fetch_heap_tuple(ti, false, &should_free);
HeapTuple new_tuple = heap_copytuple(tuple);
FormData_bgw_job *fd = (FormData_bgw_job *) GETSTRUCT(new_tuple);
HeapTuple mod_tuple;
TimestampTz next_start;

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the following lines belong to the variable declaration block it can be valuable to remove this new line.

Datum values[Natts_bgw_job] = {0};
bool isnull[Natts_bgw_job] = {0};
bool repl[Natts_bgw_job] = {0};

Copy link
Contributor

Choose a reason for hiding this comment

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

May be no new line here.

Comment on lines +918 to +919
slot_getattr(ti->slot, Anum_bgw_job_schedule_interval, &isnull[0]);
Assert(!isnull[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

New line will be an advantage here:

Suggested change
slot_getattr(ti->slot, Anum_bgw_job_schedule_interval, &isnull[0]);
Assert(!isnull[0]);
slot_getattr(ti->slot, Anum_bgw_job_schedule_interval, &isnull[0]);
Assert(!isnull[0]);

src/bgw/job.c Outdated
@@ -907,21 +907,25 @@ bgw_job_tuple_update_by_id(TupleInfo *ti, void *const data)
BgwJob *updated_job = (BgwJob *) data;
bool should_free;
HeapTuple tuple = ts_scanner_fetch_heap_tuple(ti, false, &should_free);
HeapTuple new_tuple = heap_copytuple(tuple);
FormData_bgw_job *fd = (FormData_bgw_job *) GETSTRUCT(new_tuple);
HeapTuple mod_tuple;
Copy link
Contributor

Choose a reason for hiding this comment

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

mod_tuple is confusing name. I recommend to use the original name new_tuple, which is common name in all places in our code.

Copy link
Contributor

Choose a reason for hiding this comment

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

newtuple is also common for PG code.

@svenklemm svenklemm force-pushed the fix_alter_job branch 2 times, most recently from 86039f1 to 9a04cfe Compare September 18, 2020 22:30
Fix bgw_job_tuple_update_by_id to also update scheduled and config
field of bgw_job.
@svenklemm svenklemm merged commit 6d7d99a into timescale:master Sep 18, 2020
@svenklemm svenklemm deleted the fix_alter_job branch April 18, 2021 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bgw The background worker subsystem, including the scheduler bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alter_job fails to update job config
4 participants