Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/spock_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,32 @@ spock_group_progress_update_ptr(SpockGroupEntry *e,
/*
* apply_worker_get_progress
*
* Return a pointer to the current apply worker's progress payload, or NULL
* Return a pointer to the snapshot of the current apply worker's progress.
*/
SpockApplyProgress *
apply_worker_get_progress(void)
{
static SpockApplyProgress sap;

Assert(MyApplyWorker != NULL);
Assert(MyApplyWorker->apply_group != NULL);

if (MyApplyWorker && MyApplyWorker->apply_group)
return &MyApplyWorker->apply_group->progress;
{
LWLockAcquire(SpockCtx->apply_group_master_lock, LW_SHARED);

memcpy(&sap, &MyApplyWorker->apply_group->progress,
sizeof(SpockApplyProgress));
LWLockRelease(SpockCtx->apply_group_master_lock);
}
else
/*
* Should never happen. In production just send the worker into
* exception behaviour without crash.
*/
elog(ERROR, "apply worker has not been fully initialised yet");

return NULL;
return &sap;
}

/* Iterate all groups */
Expand Down