Make IsInstallXLogFileSegmentActive() an assert-only function
Started by Bharath Rupireddyabout 3 years ago1 messages
Hi,
IsInstallXLogFileSegmentActive() is currently being used for assert
checks. How about making it an assert-only function to disable it on
production builds? This can shave an unused function on production
builds. We can easily switch back when there comes a real caller
outside of xlog.c. I'm attaching a tiny patch for this.
Thoughts?
--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachments:
v1-0001-Make-IsInstallXLogFileSegmentActive-an-assert-onl.patchapplication/octet-stream; name=v1-0001-Make-IsInstallXLogFileSegmentActive-an-assert-onl.patchDownload
From 34679d1e27e928fcd013c10772d56feb9c299bcc Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Mon, 26 Dec 2022 12:36:20 +0000
Subject: [PATCH v1] Make IsInstallXLogFileSegmentActive() an assert-only
function
---
src/backend/access/transam/xlog.c | 2 ++
src/include/access/xlog.h | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 91473b00d9..9ac33534ba 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8904,6 +8904,7 @@ SetInstallXLogFileSegmentActive(void)
LWLockRelease(ControlFileLock);
}
+#ifdef USE_ASSERT_CHECKING
bool
IsInstallXLogFileSegmentActive(void)
{
@@ -8915,6 +8916,7 @@ IsInstallXLogFileSegmentActive(void)
return result;
}
+#endif
/*
* Update the WalWriterSleeping flag.
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 1fbd48fbda..2a1e44631c 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -255,7 +255,11 @@ extern bool XLogCheckpointNeeded(XLogSegNo new_segno);
extern void SwitchIntoArchiveRecovery(XLogRecPtr EndRecPtr, TimeLineID replayTLI);
extern void ReachedEndOfBackup(XLogRecPtr EndRecPtr, TimeLineID tli);
extern void SetInstallXLogFileSegmentActive(void);
+
+#ifdef USE_ASSERT_CHECKING
extern bool IsInstallXLogFileSegmentActive(void);
+#endif
+
extern void XLogShutdownWalRcv(void);
/*
--
2.34.1