Skip to content

Commit 3865fc6

Browse files
committed
Cosmetic changes
1 parent 69bad3a commit 3865fc6

File tree

2 files changed

+0
-203
lines changed

2 files changed

+0
-203
lines changed

src/backend/access/transam/xact.c

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,72 +1263,6 @@ AtSubStart_ResourceOwner(void)
12631263
CurrentResourceOwner = s->curTransactionOwner;
12641264
}
12651265

1266-
/*
1267-
* Helper function to look at the current active snapshot and return the
1268-
* max LSN among xmin, xmax and xips
1269-
*/
1270-
1271-
//XLogRecPtr
1272-
//getMaxLSNFromSnapshot()
1273-
//{
1274-
// //pg_snapshot *snap;
1275-
// TransactionId snapXmin, snapXmax, snapInflightXid;
1276-
// XLogRecPtr maxLSN;
1277-
// uint32 nxip,
1278-
// i;
1279-
// Snapshot cur;
1280-
// //FullTransactionId next_fxid = ReadNextFullTransactionId();
1281-
//
1282-
// //if(!ActiveSnapshotSet())
1283-
// //{
1284-
// // elog(INFO, "no active snapshot set");
1285-
// // return InvalidXLogRecPtr;
1286-
// //}
1287-
//
1288-
// //cur = GetActiveSnapshot();
1289-
// //cur = GetLatestSnapshot();
1290-
// cur = GetTransactionSnapshot();
1291-
// if (cur == NULL)
1292-
// elog(ERROR, "no active snapshot set");
1293-
//
1294-
// /*
1295-
// * Compile-time limits on the procarray (MAX_BACKENDS processes plus
1296-
// * MAX_BACKENDS prepared transactions) guarantee nxip won't be too large.
1297-
// */
1298-
// //StaticAssertStmt(MAX_BACKENDS * 2 <= PG_SNAPSHOT_MAX_NXIP,
1299-
// // "possible overflow in pg_current_snapshot()");
1300-
//
1301-
// /* allocate */
1302-
// nxip = cur->xcnt;
1303-
// //snap = palloc(PG_SNAPSHOT_SIZE(nxip));
1304-
//
1305-
// /* fill */
1306-
// snapXmin = cur->xmin;
1307-
// snapXmax = cur->xmax;
1308-
//
1309-
// // An xid >= xmax is in-progress. So, we don't want to unnecessarily wait
1310-
// // in this case
1311-
// if(snapXmin == snapXmax)
1312-
// return 0;
1313-
// //snap->nxip = nxip;
1314-
//
1315-
// maxLSN = Max(TransactionIdGetCommitLSN(snapXmin), TransactionIdGetCommitLSN(snapXmax));
1316-
//
1317-
//
1318-
// for (i = 0; i < nxip; i++)
1319-
// {
1320-
// snapInflightXid = cur->xip[i];
1321-
//
1322-
// XLogRecPtr snapInFlightLSN = TransactionIdGetCommitLSN(snapInflightXid);
1323-
//
1324-
// if(snapInFlightLSN > maxLSN)
1325-
// maxLSN = snapInFlightLSN;
1326-
// }
1327-
//
1328-
// return maxLSN;
1329-
//}
1330-
1331-
13321266
/* ----------------------------------------------------------------
13331267
* CommitTransaction stuff
13341268
* ----------------------------------------------------------------

src/backend/replication/syncrep.c

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,7 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit /*, bool readOnlyWait */)
217217
*/
218218
MyProc->waitLSN = lsn;
219219
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))
226220
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-
//}
237221

238222
Assert(SyncRepQueueIsOrderedByLSN(mode));
239223
LWLockRelease(SyncRepLock);
@@ -252,7 +236,6 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit /*, bool readOnlyWait */)
252236
new_status[len] = '\0'; /* truncate off " waiting ..." */
253237
}
254238

255-
//elog(INFO, "Before the wait loop in syncrep");
256239
/*
257240
* Wait for specified LSN to be confirmed.
258241
*
@@ -320,10 +303,8 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit /*, bool readOnlyWait */)
320303
* Wait on latch. Any condition that should wake us up will set the
321304
* latch, so no need for timeout.
322305
*/
323-
//elog(INFO, "before waitlatch");
324306
rc = WaitLatch(MyLatch, WL_LATCH_SET | WL_POSTMASTER_DEATH, -1,
325307
WAIT_EVENT_SYNC_REP);
326-
//elog(INFO, "after waitlatch");
327308

328309
/*
329310
* If the postmaster dies, we'll probably never get an acknowledgment,
@@ -649,92 +630,6 @@ SyncRepGetSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr,
649630
return true;
650631
}
651632

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-
738633
/*
739634
* Calculate the oldest Write, Flush and Apply positions among sync standbys.
740635
*/
@@ -767,38 +662,6 @@ SyncRepGetOldestSyncRecPtr(XLogRecPtr *writePtr,
767662
}
768663
}
769664

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-
802665
/*
803666
* Calculate the Nth latest Write, Flush and Apply positions among sync
804667
* standbys.

0 commit comments

Comments
 (0)