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

Stop logging notices and repeating log messages #378

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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: 18 additions & 2 deletions src/pg_cron.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static void ManageCronTask(CronTask *task, TimestampTz currentTime);
static void ExecuteSqlString(const char *sql);
static void GetTaskFeedback(PGresult *result, CronTask *task);
static void ProcessBgwTaskFeedback(CronTask *task, bool running);
static void CronNoticeReceiver(void *arg, const PGresult *result);

static bool jobCanceled(CronTask *task);
static bool jobStartupTimeout(CronTask *task, TimestampTz currentTime);
Expand Down Expand Up @@ -1367,6 +1368,7 @@ ManageCronTask(CronTask *task, TimestampTz currentTime)

connection = PQconnectStartParams(keywordArray, valueArray, false);
PQsetnonblocking(connection, 1);
PQsetNoticeReceiver(connection, CronNoticeReceiver, (void *) task);

connectionStatus = PQstatus(connection);
if (connectionStatus == CONNECTION_BAD)
Expand Down Expand Up @@ -1997,8 +1999,11 @@ ProcessBgwTaskFeedback(CronTask *task, bool running)
UpdateJobRunDetail(task->runId, NULL, GetCronStatus(CRON_STATUS_SUCCEEDED), display_msg.data, NULL, &end_time);
}

ereport(LOG, (errmsg("cron job " INT64_FORMAT ": %s",
task->jobId, display_msg.data)));
/*
* We do not log the message, since the original process probably
* already did that.
*/

pfree(display_msg.data);

break;
Expand Down Expand Up @@ -2359,3 +2364,14 @@ jobStartupTimeout(CronTask *task, TimestampTz currentTime)
else
return false;
}


/*
* CronNoticeReceiver processes a libpq notice. We generally ignore
* these because they are usually already logged by the original process.
*/
static void
CronNoticeReceiver(void *arg, const PGresult *result)
{

}