Skip to content

Commit 88c6cff

Browse files
committed
Improve code comments
Author: Erik Rijkers <er@xs4all.nl>
1 parent ae1aa28 commit 88c6cff

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/backend/replication/logical/tablesync.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
* logical replication.
1313
*
1414
* The initial data synchronization is done separately for each table,
15-
* in separate apply worker that only fetches the initial snapshot data
16-
* from the publisher and then synchronizes the position in stream with
15+
* in a separate apply worker that only fetches the initial snapshot data
16+
* from the publisher and then synchronizes the position in the stream with
1717
* the main apply worker.
1818
*
19-
* The are several reasons for doing the synchronization this way:
19+
* There are several reasons for doing the synchronization this way:
2020
* - It allows us to parallelize the initial data synchronization
2121
* which lowers the time needed for it to happen.
2222
* - The initial synchronization does not have to hold the xid and LSN
2323
* for the time it takes to copy data of all tables, causing less
2424
* bloat and lower disk consumption compared to doing the
25-
* synchronization in single process for whole database.
26-
* - It allows us to synchronize the tables added after the initial
25+
* synchronization in a single process for the whole database.
26+
* - It allows us to synchronize any tables added after the initial
2727
* synchronization has finished.
2828
*
2929
* The stream position synchronization works in multiple steps.
@@ -147,7 +147,7 @@ finish_sync_worker(void)
147147
}
148148

149149
/*
150-
* Wait until the relation synchronization state is set in catalog to the
150+
* Wait until the relation synchronization state is set in the catalog to the
151151
* expected one.
152152
*
153153
* Used when transitioning from CATCHUP state to SYNCDONE.
@@ -206,12 +206,12 @@ wait_for_relation_state_change(Oid relid, char expected_state)
206206
}
207207

208208
/*
209-
* Wait until the the apply worker changes the state of our synchronization
209+
* Wait until the apply worker changes the state of our synchronization
210210
* worker to the expected one.
211211
*
212212
* Used when transitioning from SYNCWAIT state to CATCHUP.
213213
*
214-
* Returns false if the apply worker has disappeared or table state has been
214+
* Returns false if the apply worker has disappeared or the table state has been
215215
* reset.
216216
*/
217217
static bool
@@ -225,7 +225,7 @@ wait_for_worker_state_change(char expected_state)
225225

226226
CHECK_FOR_INTERRUPTS();
227227

228-
/* Bail if he apply has died. */
228+
/* Bail if the apply has died. */
229229
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
230230
worker = logicalrep_worker_find(MyLogicalRepWorker->subid,
231231
InvalidOid, false);
@@ -333,7 +333,7 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
333333

334334
Assert(!IsTransactionState());
335335

336-
/* We need up to date sync state info for subscription tables here. */
336+
/* We need up-to-date sync state info for subscription tables here. */
337337
if (!table_states_valid)
338338
{
339339
MemoryContext oldctx;
@@ -365,7 +365,7 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
365365
}
366366

367367
/*
368-
* Prepare hash table for tracking last start times of workers, to avoid
368+
* Prepare a hash table for tracking last start times of workers, to avoid
369369
* immediate restarts. We don't need it if there are no tables that need
370370
* syncing.
371371
*/
@@ -401,7 +401,7 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
401401
{
402402
/*
403403
* Apply has caught up to the position where the table sync has
404-
* finished. Time to mark the table as ready so that apply will
404+
* finished. Mark the table as ready so that the apply will
405405
* just continue to replicate it normally.
406406
*/
407407
if (current_lsn >= rstate->lsn)
@@ -436,7 +436,7 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
436436
else
437437

438438
/*
439-
* If no sync worker for this table yet, count running sync
439+
* If there is no sync worker for this table yet, count running sync
440440
* workers for this subscription, while we have the lock, for
441441
* later.
442442
*/
@@ -477,7 +477,7 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
477477

478478
/*
479479
* If there is no sync worker registered for the table and there
480-
* is some free sync worker slot, start new sync worker for the
480+
* is some free sync worker slot, start a new sync worker for the
481481
* table.
482482
*/
483483
else if (!syncworker && nsyncworkers < max_sync_workers_per_subscription)
@@ -551,7 +551,7 @@ copy_read_data(void *outbuf, int minread, int maxread)
551551
int bytesread = 0;
552552
int avail;
553553

554-
/* If there are some leftover data from previous read, use them. */
554+
/* If there are some leftover data from previous read, use it. */
555555
avail = copybuf->len - copybuf->cursor;
556556
if (avail)
557557
{
@@ -694,7 +694,7 @@ fetch_remote_table_info(char *nspname, char *relname,
694694
(errmsg("could not fetch table info for table \"%s.%s\": %s",
695695
nspname, relname, res->err)));
696696

697-
/* We don't know number of rows coming, so allocate enough space. */
697+
/* We don't know the number of rows coming, so allocate enough space. */
698698
lrel->attnames = palloc0(MaxTupleAttributeNumber * sizeof(char *));
699699
lrel->atttyps = palloc0(MaxTupleAttributeNumber * sizeof(Oid));
700700
lrel->attkeys = NULL;
@@ -852,22 +852,22 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
852852
pgstat_report_stat(false);
853853

854854
/*
855-
* We want to do the table data sync in single transaction.
855+
* We want to do the table data sync in a single transaction.
856856
*/
857857
StartTransactionCommand();
858858

859859
/*
860-
* Use standard write lock here. It might be better to
861-
* disallow access to table while it's being synchronized. But
860+
* Use a standard write lock here. It might be better to
861+
* disallow access to the table while it's being synchronized. But
862862
* we don't want to block the main apply process from working
863-
* and it has to open relation in RowExclusiveLock when
863+
* and it has to open the relation in RowExclusiveLock when
864864
* remapping remote relation id to local one.
865865
*/
866866
rel = heap_open(MyLogicalRepWorker->relid, RowExclusiveLock);
867867

868868
/*
869-
* Create temporary slot for the sync process. We do this
870-
* inside transaction so that we can use the snapshot made by
869+
* Create a temporary slot for the sync process. We do this
870+
* inside the transaction so that we can use the snapshot made by
871871
* the slot to get existing data.
872872
*/
873873
res = walrcv_exec(wrconn,
@@ -883,7 +883,7 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
883883
* Create new temporary logical decoding slot.
884884
*
885885
* We'll use slot for data copy so make sure the snapshot is
886-
* used for the transaction, that way the COPY will get data
886+
* used for the transaction; that way the COPY will get data
887887
* that is consistent with the lsn used by the slot to start
888888
* decoding.
889889
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy