@@ -217,23 +217,7 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit /*, bool readOnlyWait */)
217
217
*/
218
218
MyProc -> waitLSN = lsn ;
219
219
MyProc -> syncRepState = SYNC_REP_WAITING ;
220
- //PGPROC *proc;
221
- //proc = (PGPROC *) SHMQueueNext(&(WalSndCtl->SyncRepQueue[mode]),
222
- // &(WalSndCtl->SyncRepQueue[mode]),
223
- // offsetof(PGPROC, syncRepLinks));
224
-
225
- //if(!readOnlyWait || (readOnlyWait && proc))
226
220
SyncRepQueueInsert (mode );
227
- //if(!commit)
228
- // elog(INFO, "RO Queue length = (%d)", SyncRepGetQueueLength(mode));
229
- //else
230
- // elog(INFO, "Write Queue length = (%d)", SyncRepGetQueueLength(mode));
231
-
232
- //else
233
- //{
234
- // LWLockRelease(SyncRepLock);
235
- // return;
236
- //}
237
221
238
222
Assert (SyncRepQueueIsOrderedByLSN (mode ));
239
223
LWLockRelease (SyncRepLock );
@@ -252,7 +236,6 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit /*, bool readOnlyWait */)
252
236
new_status [len ] = '\0' ; /* truncate off " waiting ..." */
253
237
}
254
238
255
- //elog(INFO, "Before the wait loop in syncrep");
256
239
/*
257
240
* Wait for specified LSN to be confirmed.
258
241
*
@@ -320,10 +303,8 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit /*, bool readOnlyWait */)
320
303
* Wait on latch. Any condition that should wake us up will set the
321
304
* latch, so no need for timeout.
322
305
*/
323
- //elog(INFO, "before waitlatch");
324
306
rc = WaitLatch (MyLatch , WL_LATCH_SET | WL_POSTMASTER_DEATH , -1 ,
325
307
WAIT_EVENT_SYNC_REP );
326
- //elog(INFO, "after waitlatch");
327
308
328
309
/*
329
310
* If the postmaster dies, we'll probably never get an acknowledgment,
@@ -649,92 +630,6 @@ SyncRepGetSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr,
649
630
return true;
650
631
}
651
632
652
- /*
653
- * Calculate the latest synced Write, Flush and Apply positions among sync standbys.
654
- *
655
- * Return false if the number of sync standbys is less than
656
- * synchronous_standby_names specifies. Otherwise return true and
657
- * store the positions into *writePtr, *flushPtr and *applyPtr.
658
- *
659
- * On return, *am_sync is set to true if this walsender is connecting to
660
- * sync standby. Otherwise it's set to false.
661
- */
662
- static bool
663
- SyncRepGetLatestSyncRecPtr (XLogRecPtr * writePtr , XLogRecPtr * flushPtr ,
664
- XLogRecPtr * applyPtr )
665
- {
666
- SyncRepStandbyData * sync_standbys ;
667
- int num_standbys ;
668
- int i ;
669
-
670
- /* Initialize default results */
671
- * writePtr = InvalidXLogRecPtr ;
672
- * flushPtr = InvalidXLogRecPtr ;
673
- * applyPtr = InvalidXLogRecPtr ;
674
-
675
- /* Quick out if not even configured to be synchronous */
676
- if (SyncRepConfig == NULL )
677
- return false;
678
-
679
- ///* Get standbys that are considered as synchronous at this moment */
680
- num_standbys = SyncRepGetCandidateStandbys (& sync_standbys );
681
-
682
- ///* Am I among the candidate sync standbys? */
683
- //for (i = 0; i < num_standbys; i++)
684
- //{
685
- // if (sync_standbys[i].is_me)
686
- // {
687
- // *am_sync = true;
688
- // break;
689
- // }
690
- //}
691
-
692
- ///*
693
- // * Nothing more to do if we are not managing a sync standby or there are
694
- // * not enough synchronous standbys.
695
- // */
696
- //if(!overrideAmSync)
697
- //{
698
- // if (!(*am_sync) ||
699
- // num_standbys < SyncRepConfig->num_sync)
700
- // {
701
- // elog(INFO, "Not enough standbys, returning. num_standbys = (%d), num_sync = (%d)", num_standbys, SyncRepConfig->num_sync);
702
- // pfree(sync_standbys);
703
- // return false;
704
- // }
705
- //}
706
-
707
- /*
708
- * In a priority-based sync replication, the synced positions are the
709
- * oldest ones among sync standbys. In a quorum-based, they are the Nth
710
- * latest ones.
711
- *
712
- * SyncRepGetNthLatestSyncRecPtr() also can calculate the oldest
713
- * positions. But we use SyncRepGetOldestSyncRecPtr() for that calculation
714
- * because it's a bit more efficient.
715
- *
716
- * XXX If the numbers of current and requested sync standbys are the same,
717
- * we can use SyncRepGetOldestSyncRecPtr() to calculate the synced
718
- * positions even in a quorum-based sync replication.
719
- */
720
- SyncRepGetNewestSyncRecPtr (writePtr , flushPtr , applyPtr ,
721
- sync_standbys , num_standbys );
722
- //if (SyncRepConfig->syncrep_method == SYNC_REP_PRIORITY)
723
- //{
724
- // SyncRepGetOldestSyncRecPtr(writePtr, flushPtr, applyPtr,
725
- // sync_standbys, num_standbys);
726
- //}
727
- //else
728
- //{
729
- // SyncRepGetNthLatestSyncRecPtr(writePtr, flushPtr, applyPtr,
730
- // sync_standbys, num_standbys,
731
- // SyncRepConfig->num_sync);
732
- //}
733
-
734
- pfree (sync_standbys );
735
- return true;
736
- }
737
-
738
633
/*
739
634
* Calculate the oldest Write, Flush and Apply positions among sync standbys.
740
635
*/
@@ -767,38 +662,6 @@ SyncRepGetOldestSyncRecPtr(XLogRecPtr *writePtr,
767
662
}
768
663
}
769
664
770
- /*
771
- * Calculate the newest Write, Flush and Apply positions among sync standbys.
772
- */
773
- static void
774
- SyncRepGetNewestSyncRecPtr (XLogRecPtr * writePtr ,
775
- XLogRecPtr * flushPtr ,
776
- XLogRecPtr * applyPtr ,
777
- SyncRepStandbyData * sync_standbys ,
778
- int num_standbys )
779
- {
780
- int i ;
781
-
782
- /*
783
- * Scan through all sync standbys and calculate the oldest Write, Flush
784
- * and Apply positions. We assume *writePtr et al were initialized to
785
- * InvalidXLogRecPtr.
786
- */
787
- for (i = 0 ; i < num_standbys ; i ++ )
788
- {
789
- XLogRecPtr write = sync_standbys [i ].write ;
790
- XLogRecPtr flush = sync_standbys [i ].flush ;
791
- XLogRecPtr apply = sync_standbys [i ].apply ;
792
-
793
- if (XLogRecPtrIsInvalid (* writePtr ) || * writePtr < write )
794
- * writePtr = write ;
795
- if (XLogRecPtrIsInvalid (* flushPtr ) || * flushPtr < flush )
796
- * flushPtr = flush ;
797
- if (XLogRecPtrIsInvalid (* applyPtr ) || * applyPtr < apply )
798
- * applyPtr = apply ;
799
- }
800
- }
801
-
802
665
/*
803
666
* Calculate the Nth latest Write, Flush and Apply positions among sync
804
667
* standbys.
0 commit comments