diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 9d9b838..28b99d8 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2323,6 +2323,16 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
 				nbytes = npages * (Size) XLOG_BLCKSZ - startidx_offset;
 
 			nleft = nbytes;
+
+			/* If WAL written by backend is more than uint64 bytes, then log it */
+			if (PG_UINT64_MAX - WALBytesWritten < nbytes)
+			{
+				elog(LOG, "WAL Overflowed; Session (%d) writes WAL " UINT64_FORMAT,  MyProcPid, WALBytesWritten);
+				WALBytesWritten = 0;
+			}
+
+			WALBytesWritten += nbytes;
+
 			do
 			{
 				errno = 0;
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index 6bc0b06..ffad6bb 100644
--- a/src/backend/storage/ipc/ipc.c
+++ b/src/backend/storage/ipc/ipc.c
@@ -138,6 +138,8 @@ proc_exit(int code)
 	}
 #endif
 
+	elog(LOG, "Session (%d) writes WAL " UINT64_FORMAT, MyProcPid, WALBytesWritten);
+
 	elog(DEBUG3, "exit(%d)", code);
 
 	exit(code);
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 23e594e..d188a61 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -34,6 +34,8 @@ volatile uint32 InterruptHoldoffCount = 0;
 volatile uint32 QueryCancelHoldoffCount = 0;
 volatile uint32 CritSectionCount = 0;
 
+uint64 WALBytesWritten = 0;
+
 int			MyProcPid;
 pg_time_t	MyStartTime;
 struct Port *MyProcPort;
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index e0d464e..ae285b9 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -88,6 +88,9 @@ extern PGDLLIMPORT volatile uint32 InterruptHoldoffCount;
 extern PGDLLIMPORT volatile uint32 QueryCancelHoldoffCount;
 extern PGDLLIMPORT volatile uint32 CritSectionCount;
 
+
+extern PGDLLIMPORT uint64 WALBytesWritten;
+
 /* in tcop/postgres.c */
 extern void ProcessInterrupts(void);
 
