mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-20 04:35:00 +08:00
Ensure fixed_schedule field is populated
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.
This commit is contained in:
parent
ecd88f8c8e
commit
50df2516e2
@ -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
|
* handle them below. We can only use memcpy for the non-nullable fixed
|
||||||
* width starting part of the BgwJob struct.
|
* 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));
|
||||||
|
|
||||||
if (should_free)
|
if (should_free)
|
||||||
heap_freetuple(tuple);
|
heap_freetuple(tuple);
|
||||||
@ -390,21 +390,15 @@ ts_bgw_job_get_scheduled(size_t alloc_size, MemoryContext mctx)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* handle NULL columns */
|
/* handle NULL columns */
|
||||||
value = slot_getattr(ti->slot, Anum_bgw_job_hypertable_id, &isnull);
|
|
||||||
job->fd.hypertable_id = isnull ? 0 : DatumGetInt32(value);
|
|
||||||
|
|
||||||
initial_start = slot_getattr(ti->slot, Anum_bgw_job_initial_start, &initial_start_isnull);
|
initial_start = slot_getattr(ti->slot, Anum_bgw_job_initial_start, &initial_start_isnull);
|
||||||
if (!initial_start_isnull)
|
if (!initial_start_isnull)
|
||||||
job->fd.initial_start = DatumGetTimestampTz(initial_start);
|
job->fd.initial_start = DatumGetTimestampTz(initial_start);
|
||||||
else
|
else
|
||||||
job->fd.initial_start = DT_NOBEGIN;
|
job->fd.initial_start = DT_NOBEGIN;
|
||||||
timezone = slot_getattr(ti->slot, Anum_bgw_job_timezone, &timezone_isnull);
|
|
||||||
if (!timezone_isnull)
|
value = slot_getattr(ti->slot, Anum_bgw_job_hypertable_id, &isnull);
|
||||||
job->fd.timezone = DatumGetTextPP(timezone);
|
job->fd.hypertable_id = isnull ? 0 : DatumGetInt32(value);
|
||||||
else
|
|
||||||
job->fd.timezone = NULL;
|
|
||||||
|
|
||||||
/* We skip config, check_name, and check_schema since the scheduler
|
/* We skip config, check_name, and check_schema since the scheduler
|
||||||
* doesn't need these, it saves us from detoasting, and simplifies
|
* doesn't need these, it saves us from detoasting, and simplifies
|
||||||
@ -412,6 +406,12 @@ ts_bgw_job_get_scheduled(size_t alloc_size, MemoryContext mctx)
|
|||||||
* would have to be freed separately when freeing a job. */
|
* would have to be freed separately when freeing a job. */
|
||||||
job->fd.config = NULL;
|
job->fd.config = NULL;
|
||||||
|
|
||||||
|
timezone = slot_getattr(ti->slot, Anum_bgw_job_timezone, &timezone_isnull);
|
||||||
|
if (!timezone_isnull)
|
||||||
|
job->fd.timezone = DatumGetTextPP(timezone);
|
||||||
|
else
|
||||||
|
job->fd.timezone = NULL;
|
||||||
|
|
||||||
old_ctx = MemoryContextSwitchTo(mctx);
|
old_ctx = MemoryContextSwitchTo(mctx);
|
||||||
jobs = lappend(jobs, job);
|
jobs = lappend(jobs, job);
|
||||||
MemoryContextSwitchTo(old_ctx);
|
MemoryContextSwitchTo(old_ctx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user