diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 7ad9720b2bb35083065d1188d4b6dcb40b933abd..1110cf6ffc80fa3fffa801e8f17eaff804950514 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1446,9 +1446,11 @@ index_drop(Oid indexId, bool concurrent)
 
 		/*
 		 * Now we must wait until no running transaction could be using the
-		 * index for a query. Note we do not need to worry about xacts that
-		 * open the table for reading after this point; they will see the
-		 * index as invalid when they open the relation.
+		 * index for a query.  Use AccessExclusiveLock here to check for
+		 * running transactions that hold locks of any kind on the table.
+		 * Note we do not need to worry about xacts that open the table for
+		 * reading after this point; they will see the index as invalid when
+		 * they open the relation.
 		 *
 		 * Note: the reason we use actual lock acquisition here, rather than
 		 * just checking the ProcArray and sleeping, is that deadlock is
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 9b97e44867a99584400746f35c650da6d25e46e0..ec66f7872530ec3e5788cc68fa40fbea923f0b46 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -651,9 +651,10 @@ DefineIndex(IndexStmt *stmt,
 	 * for an overview of how this works)
 	 *
 	 * Now we must wait until no running transaction could have the table open
-	 * with the old list of indexes. Note we do not need to worry about xacts
-	 * that open the table for writing after this point; they will see the new
-	 * index when they open it.
+	 * with the old list of indexes.  Use ShareLock to consider running
+	 * transactions that hold locks that permit writing to the table.  Note we
+	 * do not need to worry about xacts that open the table for writing after
+	 * this point; they will see the new index when they open it.
 	 *
 	 * Note: the reason we use actual lock acquisition here, rather than just
 	 * checking the ProcArray and sleeping, is that deadlock is possible if