mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Post-PG 10 beta1 pgindent run
perltidy run not included.
This commit is contained in:
@@ -166,7 +166,7 @@ typedef struct GlobalTransactionData
|
||||
*/
|
||||
XLogRecPtr prepare_start_lsn; /* XLOG offset of prepare record start */
|
||||
XLogRecPtr prepare_end_lsn; /* XLOG offset of prepare record end */
|
||||
TransactionId xid; /* The GXACT id */
|
||||
TransactionId xid; /* The GXACT id */
|
||||
|
||||
Oid owner; /* ID of user that executed the xact */
|
||||
BackendId locking_backend; /* backend currently working on the xact */
|
||||
@@ -220,11 +220,11 @@ static void RemoveGXact(GlobalTransaction gxact);
|
||||
|
||||
static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len);
|
||||
static char *ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
XLogRecPtr prepare_start_lsn,
|
||||
bool fromdisk, bool setParent, bool setNextXid);
|
||||
XLogRecPtr prepare_start_lsn,
|
||||
bool fromdisk, bool setParent, bool setNextXid);
|
||||
static void MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid,
|
||||
const char *gid, TimestampTz prepared_at, Oid owner,
|
||||
Oid databaseid);
|
||||
const char *gid, TimestampTz prepared_at, Oid owner,
|
||||
Oid databaseid);
|
||||
static void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning);
|
||||
static void RecreateTwoPhaseFile(TransactionId xid, void *content, int len);
|
||||
|
||||
@@ -1304,7 +1304,7 @@ XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory"),
|
||||
errdetail("Failed while allocating a WAL reading processor.")));
|
||||
errdetail("Failed while allocating a WAL reading processor.")));
|
||||
|
||||
record = XLogReadRecord(xlogreader, lsn, &errormsg);
|
||||
if (record == NULL)
|
||||
@@ -1318,9 +1318,9 @@ XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
|
||||
(XLogRecGetInfo(xlogreader) & XLOG_XACT_OPMASK) != XLOG_XACT_PREPARE)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("expected two-phase state data is not present in WAL at %X/%X",
|
||||
(uint32) (lsn >> 32),
|
||||
(uint32) lsn)));
|
||||
errmsg("expected two-phase state data is not present in WAL at %X/%X",
|
||||
(uint32) (lsn >> 32),
|
||||
(uint32) lsn)));
|
||||
|
||||
if (len != NULL)
|
||||
*len = XLogRecGetDataLen(xlogreader);
|
||||
@@ -1675,7 +1675,10 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
|
||||
LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
|
||||
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
|
||||
{
|
||||
/* Note that we are using gxact not pgxact so this works in recovery also */
|
||||
/*
|
||||
* Note that we are using gxact not pgxact so this works in recovery
|
||||
* also
|
||||
*/
|
||||
GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
|
||||
|
||||
if ((gxact->valid || gxact->inredo) &&
|
||||
@@ -1727,8 +1730,8 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
|
||||
void
|
||||
restoreTwoPhaseData(void)
|
||||
{
|
||||
DIR *cldir;
|
||||
struct dirent *clde;
|
||||
DIR *cldir;
|
||||
struct dirent *clde;
|
||||
|
||||
cldir = AllocateDir(TWOPHASE_DIR);
|
||||
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
|
||||
@@ -1801,8 +1804,8 @@ PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
|
||||
xid = gxact->xid;
|
||||
|
||||
buf = ProcessTwoPhaseBuffer(xid,
|
||||
gxact->prepare_start_lsn,
|
||||
gxact->ondisk, false, true);
|
||||
gxact->prepare_start_lsn,
|
||||
gxact->ondisk, false, true);
|
||||
|
||||
if (buf == NULL)
|
||||
continue;
|
||||
@@ -1876,8 +1879,8 @@ StandbyRecoverPreparedTransactions(void)
|
||||
xid = gxact->xid;
|
||||
|
||||
buf = ProcessTwoPhaseBuffer(xid,
|
||||
gxact->prepare_start_lsn,
|
||||
gxact->ondisk, false, false);
|
||||
gxact->prepare_start_lsn,
|
||||
gxact->ondisk, false, false);
|
||||
if (buf != NULL)
|
||||
pfree(buf);
|
||||
}
|
||||
@@ -1920,17 +1923,17 @@ RecoverPreparedTransactions(void)
|
||||
xid = gxact->xid;
|
||||
|
||||
/*
|
||||
* Reconstruct subtrans state for the transaction --- needed
|
||||
* because pg_subtrans is not preserved over a restart. Note that
|
||||
* we are linking all the subtransactions directly to the
|
||||
* top-level XID; there may originally have been a more complex
|
||||
* hierarchy, but there's no need to restore that exactly.
|
||||
* It's possible that SubTransSetParent has been set before, if
|
||||
* the prepared transaction generated xid assignment records.
|
||||
* Reconstruct subtrans state for the transaction --- needed because
|
||||
* pg_subtrans is not preserved over a restart. Note that we are
|
||||
* linking all the subtransactions directly to the top-level XID;
|
||||
* there may originally have been a more complex hierarchy, but
|
||||
* there's no need to restore that exactly. It's possible that
|
||||
* SubTransSetParent has been set before, if the prepared transaction
|
||||
* generated xid assignment records.
|
||||
*/
|
||||
buf = ProcessTwoPhaseBuffer(xid,
|
||||
gxact->prepare_start_lsn,
|
||||
gxact->ondisk, true, false);
|
||||
gxact->prepare_start_lsn,
|
||||
gxact->ondisk, true, false);
|
||||
if (buf == NULL)
|
||||
continue;
|
||||
|
||||
@@ -1949,9 +1952,8 @@ RecoverPreparedTransactions(void)
|
||||
bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
|
||||
|
||||
/*
|
||||
* Recreate its GXACT and dummy PGPROC. But, check whether
|
||||
* it was added in redo and already has a shmem entry for
|
||||
* it.
|
||||
* Recreate its GXACT and dummy PGPROC. But, check whether it was
|
||||
* added in redo and already has a shmem entry for it.
|
||||
*/
|
||||
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
|
||||
MarkAsPreparingGuts(gxact, xid, gid,
|
||||
@@ -1980,9 +1982,8 @@ RecoverPreparedTransactions(void)
|
||||
StandbyReleaseLockTree(xid, hdr->nsubxacts, subxids);
|
||||
|
||||
/*
|
||||
* We're done with recovering this transaction. Clear
|
||||
* MyLockedGxact, like we do in PrepareTransaction() during normal
|
||||
* operation.
|
||||
* We're done with recovering this transaction. Clear MyLockedGxact,
|
||||
* like we do in PrepareTransaction() during normal operation.
|
||||
*/
|
||||
PostPrepare_Twophase();
|
||||
|
||||
@@ -2049,8 +2050,8 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
else
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing future two-phase state from memory for \"%u\"",
|
||||
xid)));
|
||||
(errmsg("removing future two-phase state from memory for \"%u\"",
|
||||
xid)));
|
||||
PrepareRedoRemove(xid, true);
|
||||
}
|
||||
return NULL;
|
||||
@@ -2063,8 +2064,8 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
if (buf == NULL)
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing corrupt two-phase state file for \"%u\"",
|
||||
xid)));
|
||||
(errmsg("removing corrupt two-phase state file for \"%u\"",
|
||||
xid)));
|
||||
RemoveTwoPhaseFile(xid, true);
|
||||
return NULL;
|
||||
}
|
||||
@@ -2082,15 +2083,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
if (fromdisk)
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing corrupt two-phase state file for \"%u\"",
|
||||
xid)));
|
||||
(errmsg("removing corrupt two-phase state file for \"%u\"",
|
||||
xid)));
|
||||
RemoveTwoPhaseFile(xid, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing corrupt two-phase state from memory for \"%u\"",
|
||||
xid)));
|
||||
(errmsg("removing corrupt two-phase state from memory for \"%u\"",
|
||||
xid)));
|
||||
PrepareRedoRemove(xid, true);
|
||||
}
|
||||
pfree(buf);
|
||||
@@ -2098,8 +2099,8 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
}
|
||||
|
||||
/*
|
||||
* Examine subtransaction XIDs ... they should all follow main
|
||||
* XID, and they may force us to advance nextXid.
|
||||
* Examine subtransaction XIDs ... they should all follow main XID, and
|
||||
* they may force us to advance nextXid.
|
||||
*/
|
||||
subxids = (TransactionId *) (buf +
|
||||
MAXALIGN(sizeof(TwoPhaseFileHeader)) +
|
||||
@@ -2122,7 +2123,7 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
*/
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
if (TransactionIdFollowsOrEquals(subxid,
|
||||
ShmemVariableCache->nextXid))
|
||||
ShmemVariableCache->nextXid))
|
||||
{
|
||||
ShmemVariableCache->nextXid = subxid;
|
||||
TransactionIdAdvance(ShmemVariableCache->nextXid);
|
||||
@@ -2175,14 +2176,15 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
MyPgXact->delayChkpt = true;
|
||||
|
||||
/*
|
||||
* Emit the XLOG commit record. Note that we mark 2PC commits as potentially
|
||||
* having AccessExclusiveLocks since we don't know whether or not they do.
|
||||
* Emit the XLOG commit record. Note that we mark 2PC commits as
|
||||
* potentially having AccessExclusiveLocks since we don't know whether or
|
||||
* not they do.
|
||||
*/
|
||||
recptr = XactLogCommitRecord(committs,
|
||||
nchildren, children, nrels, rels,
|
||||
ninvalmsgs, invalmsgs,
|
||||
initfileinval, false,
|
||||
MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
|
||||
MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
|
||||
xid);
|
||||
|
||||
|
||||
@@ -2260,13 +2262,14 @@ RecordTransactionAbortPrepared(TransactionId xid,
|
||||
START_CRIT_SECTION();
|
||||
|
||||
/*
|
||||
* Emit the XLOG commit record. Note that we mark 2PC aborts as potentially
|
||||
* having AccessExclusiveLocks since we don't know whether or not they do.
|
||||
* Emit the XLOG commit record. Note that we mark 2PC aborts as
|
||||
* potentially having AccessExclusiveLocks since we don't know whether or
|
||||
* not they do.
|
||||
*/
|
||||
recptr = XactLogAbortRecord(GetCurrentTimestamp(),
|
||||
nchildren, children,
|
||||
nrels, rels,
|
||||
MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
|
||||
MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
|
||||
xid);
|
||||
|
||||
/* Always flush, since we're about to remove the 2PC state file */
|
||||
@@ -2301,8 +2304,8 @@ void
|
||||
PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
|
||||
{
|
||||
TwoPhaseFileHeader *hdr = (TwoPhaseFileHeader *) buf;
|
||||
char *bufptr;
|
||||
const char *gid;
|
||||
char *bufptr;
|
||||
const char *gid;
|
||||
GlobalTransaction gxact;
|
||||
|
||||
Assert(RecoveryInProgress());
|
||||
@@ -2315,8 +2318,8 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
|
||||
*
|
||||
* This creates a gxact struct and puts it into the active array.
|
||||
*
|
||||
* In redo, this struct is mainly used to track PREPARE/COMMIT entries
|
||||
* in shared memory. Hence, we only fill up the bare minimum contents here.
|
||||
* In redo, this struct is mainly used to track PREPARE/COMMIT entries in
|
||||
* shared memory. Hence, we only fill up the bare minimum contents here.
|
||||
* The gxact also gets marked with gxact->inredo set to true to indicate
|
||||
* that it got added in the redo phase
|
||||
*/
|
||||
@@ -2340,7 +2343,7 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
|
||||
gxact->locking_backend = InvalidBackendId;
|
||||
gxact->valid = false;
|
||||
gxact->ondisk = XLogRecPtrIsInvalid(start_lsn);
|
||||
gxact->inredo = true; /* yes, added in redo */
|
||||
gxact->inredo = true; /* yes, added in redo */
|
||||
strcpy(gxact->gid, gid);
|
||||
|
||||
/* And insert it into the active array */
|
||||
|
||||
Reference in New Issue
Block a user