Skip to content

Commit 237c525

Browse files
authored
Stop logging notices and repeating log messages (#378)
1 parent d50a137 commit 237c525

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/pg_cron.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static void ManageCronTask(CronTask *task, TimestampTz currentTime);
143143
static void ExecuteSqlString(const char *sql);
144144
static void GetTaskFeedback(PGresult *result, CronTask *task);
145145
static void ProcessBgwTaskFeedback(CronTask *task, bool running);
146+
static void CronNoticeReceiver(void *arg, const PGresult *result);
146147

147148
static bool jobCanceled(CronTask *task);
148149
static bool jobStartupTimeout(CronTask *task, TimestampTz currentTime);
@@ -1367,6 +1368,7 @@ ManageCronTask(CronTask *task, TimestampTz currentTime)
13671368

13681369
connection = PQconnectStartParams(keywordArray, valueArray, false);
13691370
PQsetnonblocking(connection, 1);
1371+
PQsetNoticeReceiver(connection, CronNoticeReceiver, (void *) task);
13701372

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

2000-
ereport(LOG, (errmsg("cron job " INT64_FORMAT ": %s",
2001-
task->jobId, display_msg.data)));
2002+
/*
2003+
* We do not log the message, since the original process probably
2004+
* already did that.
2005+
*/
2006+
20022007
pfree(display_msg.data);
20032008

20042009
break;
@@ -2359,3 +2364,14 @@ jobStartupTimeout(CronTask *task, TimestampTz currentTime)
23592364
else
23602365
return false;
23612366
}
2367+
2368+
2369+
/*
2370+
* CronNoticeReceiver processes a libpq notice. We generally ignore
2371+
* these because they are usually already logged by the original process.
2372+
*/
2373+
static void
2374+
CronNoticeReceiver(void *arg, const PGresult *result)
2375+
{
2376+
2377+
}

0 commit comments

Comments
 (0)