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

Ensure fixed_schedule field is populated #6181

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

jnidzwetzki
Copy link
Contributor

The jobs framework contains two functions for loading jobs (ts_bgw_job_get_scheduled and bgw_job_from_tupleinfo). However, the ts_bgw_job_get_scheduled function did not properly populate the fixed_schedule field, which caused some bugs in the calculation of the next execution time for a job. This PR ensures the fixed_schedule field is populated properly.


We have some checks in bgw_db_scheduler_fixed to test this code path. However, these tests use our mock framework and trigger only the ts_bgw_job_entrypoint -> ts_bgw_job_stat_mark_end -> [..] -> ts_scanner_scan -> bgw_job_from_tupleinfo code path for loading jobs and calculate the next execution for a failed job. Since the second code path can not be tested well at the moment, I did not add test cases and created the follow-up issue https://github.com/timescale/eng-database/issues/535 instead.

Disable-check: force-changelog-file

The jobs framework contains two functions for loading jobs
(ts_bgw_job_get_scheduled and bgw_job_from_tupleinfo). However, the
ts_bgw_job_get_scheduled function did not properly populate the
fixed_schedule field, which caused some bugs in the calculation of the
next execution time for a job. This PR ensures the fixed_schedule field
is populated properly.
@@ -377,7 +377,7 @@ ts_bgw_job_get_scheduled(size_t alloc_size, MemoryContext mctx)
* handle them below. We can only use memcpy for the non-nullable fixed
* width starting part of the BgwJob struct.
*/
memcpy(job, GETSTRUCT(tuple), offsetof(FormData_bgw_job, fixed_schedule));
memcpy(job, GETSTRUCT(tuple), offsetof(FormData_bgw_job, initial_start));
Copy link
Contributor Author

@jnidzwetzki jnidzwetzki Oct 10, 2023

Choose a reason for hiding this comment

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

The fixed_schedule field is now included and all fields starting from initial_start are initialized below.

/* handle NULL columns */
value = slot_getattr(ti->slot, Anum_bgw_job_hypertable_id, &isnull);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reordered the initialization order to match the order of the FormData_bgw_job struct.

@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #6181 (6f59b06) into main (6304c7a) will decrease coverage by 7.67%.
Report is 7 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #6181      +/-   ##
==========================================
- Coverage   81.44%   73.78%   -7.67%     
==========================================
  Files         246      246              
  Lines       56974    49821    -7153     
  Branches    12624    12505     -119     
==========================================
- Hits        46400    36758    -9642     
+ Misses       8196     7231     -965     
- Partials     2378     5832    +3454     
Files Coverage Δ
src/bgw/job.c 80.97% <100.00%> (-10.41%) ⬇️

... and 227 files with indirect coverage changes

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

@jnidzwetzki jnidzwetzki marked this pull request as ready for review October 10, 2023 10:47
@github-actions
Copy link

@erimatnor, @antekresic: please review this pull request.

Powered by pull-review

@jnidzwetzki jnidzwetzki merged commit 50df251 into timescale:main Oct 13, 2023
39 checks passed
svenklemm added a commit to svenklemm/timescaledb that referenced this pull request Oct 19, 2023
This release contains bug fixes since the 2.12.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#6155 Align gapfill bucket generation with time_bucket
* timescale#6181 Ensure fixed_schedule field is populated
* timescale#6210 Fix EXPLAIN ANALYZE for compressed DML
@svenklemm svenklemm mentioned this pull request Oct 19, 2023
svenklemm added a commit that referenced this pull request Oct 19, 2023
This release contains bug fixes since the 2.12.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #6155 Align gapfill bucket generation with time_bucket
* #6181 Ensure fixed_schedule field is populated
* #6210 Fix EXPLAIN ANALYZE for compressed DML
svenklemm added a commit to svenklemm/timescaledb that referenced this pull request Oct 19, 2023
This release contains bug fixes since the 2.12.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#6155 Align gapfill bucket generation with time_bucket
* timescale#6181 Ensure fixed_schedule field is populated
* timescale#6210 Fix EXPLAIN ANALYZE for compressed DML
@svenklemm svenklemm mentioned this pull request Oct 19, 2023
svenklemm added a commit that referenced this pull request Oct 19, 2023
This release contains bug fixes since the 2.12.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #6155 Align gapfill bucket generation with time_bucket
* #6181 Ensure fixed_schedule field is populated
* #6210 Fix EXPLAIN ANALYZE for compressed DML
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this pull request Nov 9, 2023
This release contains bug fixes since the 2.12.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#6155 Align gapfill bucket generation with time_bucket
* timescale#6181 Ensure fixed_schedule field is populated
* timescale#6210 Fix EXPLAIN ANALYZE for compressed DML
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this pull request Nov 19, 2023
This release contains bug fixes since the 2.12.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#6155 Align gapfill bucket generation with time_bucket
* timescale#6181 Ensure fixed_schedule field is populated
* timescale#6210 Fix EXPLAIN ANALYZE for compressed DML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants