diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index a1e0423..b0ee1fd 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -166,6 +166,8 @@ static double ckpt_cached_elapsed;
 static pg_time_t last_checkpoint_time;
 static pg_time_t last_xlog_switch_time;
 
+extern bool reset_latch_ok;
+
 /* Prototypes for private functions */
 
 static void CheckArchiveTimeout(void);
@@ -343,9 +345,13 @@ CheckpointerMain(void)
 		int			elapsed_secs;
 		int			cur_timeout;
 
+		reset_latch_ok = true;
+
 		/* Clear any already-pending wakeups */
 		ResetLatch(MyLatch);
 
+		reset_latch_ok = false;
+
 		/*
 		 * Process any requests or signals received recently.
 		 */
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index 59fa917..1f0613d 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -118,6 +118,8 @@ struct WaitEventSet
 #endif
 };
 
+bool reset_latch_ok = true;
+
 #ifndef WIN32
 /* Are we currently in WaitLatch? The signal handler would like to know. */
 static volatile sig_atomic_t waiting = false;
@@ -521,6 +523,8 @@ ResetLatch(Latch *latch)
 	/* Only the owner should reset the latch */
 	Assert(latch->owner_pid == MyProcPid);
 
+	Assert(reset_latch_ok);
+
 	latch->is_set = false;
 
 	/*
