diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index be357e7..9baacac7 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2165,11 +2165,22 @@ do_autovacuum(void)
 	{
 		Oid				relid = linitial_oid(orphan_oids);
 		ObjectAddress	object;
-		char		   *namespace = get_namespace_name(get_rel_namespace(relid));
-		char		   *relname = get_rel_name(relid);
+		char		   *namespace;
+		char		   *relname;
 
 		orphan_oids = list_delete_first(orphan_oids);
 
+		/*
+		 * Check if the relation still exists, it could be possible that it
+		 * has already been dropped when gathering the list of orphaned
+		 * relations by another backend.
+		 */
+		if (!ConditionalLockRelationOid(relid, AccessExclusiveLock))
+			continue;
+
+		namespace = get_namespace_name(get_rel_namespace(relid));
+		relname = get_rel_name(relid);
+
 		PG_TRY();
 		{
 			ereport(LOG,
