diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index a9a06b9a38..19730c8715 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -434,7 +434,7 @@ retry:
 	 */
 	if (active_pid != MyProcPid)
 	{
-		if (!nowait)
+		if (nowait)
 			ereport(ERROR,
 					(errcode(ERRCODE_OBJECT_IN_USE),
 					 errmsg("replication slot \"%s\" is active for PID %d",
