diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 62aa999931..188f6d6f85 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -1400,7 +1400,7 @@ read_tablespace_map(List **tablespaces)
  *
  * Returns the position of the last valid or applied record, after which new
  * WAL should be appended, information about why recovery was ended, and some
- * other things. See the WalRecoveryResult struct for details.
+ * other things. See the EndOfWalRecoveryInfo struct for details.
  */
 EndOfWalRecoveryInfo *
 FinishWalRecovery(void)
diff --git a/src/backend/backup/basebackup_copy.c b/src/backend/backup/basebackup_copy.c
index 2bb6c89f8c..73a3f4a970 100644
--- a/src/backend/backup/basebackup_copy.c
+++ b/src/backend/backup/basebackup_copy.c
@@ -3,7 +3,7 @@
  * basebackup_copy.c
  *	  send basebackup archives using COPY OUT
  *
- * We send a result set with information about the tabelspaces to be included
+ * We send a result set with information about the tablespaces to be included
  * in the backup before starting COPY OUT. Then, we start a single COPY OUT
  * operation and transmits all the archives and the manifest if present during
  * the course of that single COPY OUT. Each CopyData message begins with a
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 6dce355633..0c71ae9ba7 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -1556,7 +1556,7 @@ FetchTableStates(bool *started_tx)
 		 * Does the subscription have tables?
 		 *
 		 * If there were not-READY relations found then we know it does. But
-		 * if table_state_not_ready was empty we still need to check again to
+		 * if table_states_not_ready was empty we still need to check again to
 		 * see if there are 0 tables.
 		 */
 		has_subrels = (table_states_not_ready != NIL) ||
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index fa03cbbadf..95c3970437 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -494,7 +494,7 @@ static void tuplesort_updatemax(Tuplesortstate *state);
  * abbreviations of text or multi-key sorts.  There could be!  Is it worth it?
  */
 
-/* Used if first key's comparator is ssup_datum_unsigned_compare */
+/* Used if first key's comparator is ssup_datum_unsigned_cmp */
 static pg_attribute_always_inline int
 qsort_tuple_unsigned_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
 {
diff --git a/src/bin/pg_basebackup/bbstreamer_gzip.c b/src/bin/pg_basebackup/bbstreamer_gzip.c
index 83bf5972fa..3bdbfa0bc4 100644
--- a/src/bin/pg_basebackup/bbstreamer_gzip.c
+++ b/src/bin/pg_basebackup/bbstreamer_gzip.c
@@ -150,7 +150,7 @@ bbstreamer_gzip_writer_content(bbstreamer *streamer,
  * calling gzclose.
  *
  * It makes no difference whether we opened the file or the caller did it,
- * because libz provides no way of avoiding a close on the underling file
+ * because libz provides no way of avoiding a close on the underlying file
  * handle. Notice, however, that bbstreamer_gzip_writer_new() uses dup() to
  * work around this issue, so that the behavior from the caller's viewpoint
  * is the same as for bbstreamer_plain_writer.
diff --git a/src/test/subscription/t/029_on_error.pl b/src/test/subscription/t/029_on_error.pl
index 7797a949c2..7d6fb66985 100644
--- a/src/test/subscription/t/029_on_error.pl
+++ b/src/test/subscription/t/029_on_error.pl
@@ -13,7 +13,7 @@ my $offset = 0;
 # Test skipping the transaction. This function must be called after the caller
 # has inserted data that conflicts with the subscriber.  The finish LSN of the
 # error transaction that is used to specify to ALTER SUBSCRIPTION ... SKIP is
-# fetched from the server logs. After executing ALTER SUBSCRITPION ... SKIP, we
+# fetched from the server logs. After executing ALTER SUBSCRIPTION ... SKIP, we
 # check if logical replication can continue working by inserting $nonconflict_data
 # on the publisher.
 sub test_skip_lsn
