Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 32fd40f

Browse files
tglsfdcCommitfest Bot
authored and
Commitfest Bot
committed
Fix leaks in startup process.
These leaks are of absolutely no real-world consequence, since they are small one-time leaks in a one-time process. But this is the last step to get to zero reported leaks in a run of the core regression tests, so let's do it. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/285483.1746756246@sss.pgh.pa.us
1 parent 296550a commit 32fd40f

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/backend/access/transam/xlog.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ static void InitControlFile(uint64 sysidentifier, uint32 data_checksum_version);
703703
static void WriteControlFile(void);
704704
static void ReadControlFile(void);
705705
static void UpdateControlFile(void);
706-
static char *str_time(pg_time_t tnow);
706+
static char *str_time(pg_time_t tnow, char *buf, size_t bufsize);
707707

708708
static int get_sync_bit(int method);
709709

@@ -5381,11 +5381,9 @@ BootStrapXLOG(uint32 data_checksum_version)
53815381
}
53825382

53835383
static char *
5384-
str_time(pg_time_t tnow)
5384+
str_time(pg_time_t tnow, char *buf, size_t bufsize)
53855385
{
5386-
char *buf = palloc(128);
5387-
5388-
pg_strftime(buf, 128,
5386+
pg_strftime(buf, bufsize,
53895387
"%Y-%m-%d %H:%M:%S %Z",
53905388
pg_localtime(&tnow, log_timezone));
53915389

@@ -5628,6 +5626,7 @@ StartupXLOG(void)
56285626
XLogRecPtr missingContrecPtr;
56295627
TransactionId oldestActiveXID;
56305628
bool promoted = false;
5629+
char timebuf[128];
56315630

56325631
/*
56335632
* We should have an aux process resource owner to use, and we should not
@@ -5656,41 +5655,47 @@ StartupXLOG(void)
56565655
*/
56575656
ereport(IsPostmasterEnvironment ? LOG : NOTICE,
56585657
(errmsg("database system was shut down at %s",
5659-
str_time(ControlFile->time))));
5658+
str_time(ControlFile->time,
5659+
timebuf, sizeof(timebuf)))));
56605660
break;
56615661

56625662
case DB_SHUTDOWNED_IN_RECOVERY:
56635663
ereport(LOG,
56645664
(errmsg("database system was shut down in recovery at %s",
5665-
str_time(ControlFile->time))));
5665+
str_time(ControlFile->time,
5666+
timebuf, sizeof(timebuf)))));
56665667
break;
56675668

56685669
case DB_SHUTDOWNING:
56695670
ereport(LOG,
56705671
(errmsg("database system shutdown was interrupted; last known up at %s",
5671-
str_time(ControlFile->time))));
5672+
str_time(ControlFile->time,
5673+
timebuf, sizeof(timebuf)))));
56725674
break;
56735675

56745676
case DB_IN_CRASH_RECOVERY:
56755677
ereport(LOG,
56765678
(errmsg("database system was interrupted while in recovery at %s",
5677-
str_time(ControlFile->time)),
5679+
str_time(ControlFile->time,
5680+
timebuf, sizeof(timebuf))),
56785681
errhint("This probably means that some data is corrupted and"
56795682
" you will have to use the last backup for recovery.")));
56805683
break;
56815684

56825685
case DB_IN_ARCHIVE_RECOVERY:
56835686
ereport(LOG,
56845687
(errmsg("database system was interrupted while in recovery at log time %s",
5685-
str_time(ControlFile->checkPointCopy.time)),
5688+
str_time(ControlFile->checkPointCopy.time,
5689+
timebuf, sizeof(timebuf))),
56865690
errhint("If this has occurred more than once some data might be corrupted"
56875691
" and you might need to choose an earlier recovery target.")));
56885692
break;
56895693

56905694
case DB_IN_PRODUCTION:
56915695
ereport(LOG,
56925696
(errmsg("database system was interrupted; last known up at %s",
5693-
str_time(ControlFile->time))));
5697+
str_time(ControlFile->time,
5698+
timebuf, sizeof(timebuf)))));
56945699
break;
56955700

56965701
default:
@@ -6336,6 +6341,12 @@ StartupXLOG(void)
63366341
*/
63376342
CompleteCommitTsInitialization();
63386343

6344+
/* Clean up EndOfWalRecoveryInfo data to appease Valgrind leak checking */
6345+
if (endOfRecoveryInfo->lastPage)
6346+
pfree(endOfRecoveryInfo->lastPage);
6347+
pfree(endOfRecoveryInfo->recoveryStopReason);
6348+
pfree(endOfRecoveryInfo);
6349+
63396350
/*
63406351
* All done with end-of-recovery actions.
63416352
*

src/backend/access/transam/xlogrecovery.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,7 @@ ShutdownWalRecovery(void)
16261626
close(readFile);
16271627
readFile = -1;
16281628
}
1629+
pfree(xlogreader->private_data);
16291630
XLogReaderFree(xlogreader);
16301631
XLogPrefetcherFree(xlogprefetcher);
16311632

0 commit comments

Comments
 (0)