/* Warn any waiting backends that the checkpoint failed. */
if (ckpt_active)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
-
- SpinLockAcquire(&cps->ckpt_lck);
- cps->ckpt_failed++;
- cps->ckpt_done = cps->ckpt_started;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ CheckpointerShmem->ckpt_failed++;
+ CheckpointerShmem->ckpt_done = CheckpointerShmem->ckpt_started;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
ckpt_active = false;
}
bool ckpt_performed = false;
bool do_restartpoint;
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
-
/*
* Check if we should perform a checkpoint or a restartpoint. As a
* side-effect, RecoveryInProgress() initializes TimeLineID if
* checkpoint we should perform, and increase the started-counter
* to acknowledge that we've started a new checkpoint.
*/
- SpinLockAcquire(&cps->ckpt_lck);
- flags |= cps->ckpt_flags;
- cps->ckpt_flags = 0;
- cps->ckpt_started++;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ flags |= CheckpointerShmem->ckpt_flags;
+ CheckpointerShmem->ckpt_flags = 0;
+ CheckpointerShmem->ckpt_started++;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
/*
* The end-of-recovery checkpoint is a real checkpoint that's
/*
* Indicate checkpoint completion to any waiting backends.
*/
- SpinLockAcquire(&cps->ckpt_lck);
- cps->ckpt_done = cps->ckpt_started;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ CheckpointerShmem->ckpt_done = CheckpointerShmem->ckpt_started;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (ckpt_performed)
{
void
RequestCheckpoint(int flags)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
int ntries;
int old_failed,
old_started;
* a "stronger" request by another backend. The flag senses must be
* chosen to make this work!
*/
- SpinLockAcquire(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
- old_failed = cps->ckpt_failed;
- old_started = cps->ckpt_started;
- cps->ckpt_flags |= flags;
+ old_failed = CheckpointerShmem->ckpt_failed;
+ old_started = CheckpointerShmem->ckpt_started;
+ CheckpointerShmem->ckpt_flags |= flags;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
/*
* Send signal to request checkpoint. It's possible that the checkpointer
/* Wait for a new checkpoint to start. */
for (;;)
{
- SpinLockAcquire(&cps->ckpt_lck);
- new_started = cps->ckpt_started;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ new_started = CheckpointerShmem->ckpt_started;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (new_started != old_started)
break;
{
int new_done;
- SpinLockAcquire(&cps->ckpt_lck);
- new_done = cps->ckpt_done;
- new_failed = cps->ckpt_failed;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ new_done = CheckpointerShmem->ckpt_done;
+ new_failed = CheckpointerShmem->ckpt_failed;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (new_done - new_started >= 0)
break;
bool
FirstCallSinceLastCheckpoint(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
static int ckpt_done = 0;
int new_done;
bool FirstCall = false;
- SpinLockAcquire(&cps->ckpt_lck);
- new_done = cps->ckpt_done;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ new_done = CheckpointerShmem->ckpt_done;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (new_done != ckpt_done)
FirstCall = true;
bool updated_xmin = false;
bool updated_restart = false;
- /* use volatile pointer to prevent code rearrangement */
- volatile ReplicationSlot *slot = MyReplicationSlot;
+ SpinLockAcquire(&MyReplicationSlot->mutex);
- SpinLockAcquire(&slot->mutex);
-
- slot->data.confirmed_flush = lsn;
+ MyReplicationSlot->data.confirmed_flush = lsn;
/* if were past the location required for bumping xmin, do so */
- if (slot->candidate_xmin_lsn != InvalidXLogRecPtr &&
- slot->candidate_xmin_lsn <= lsn)
+ if (MyReplicationSlot->candidate_xmin_lsn != InvalidXLogRecPtr &&
+ MyReplicationSlot->candidate_xmin_lsn <= lsn)
{
/*
* We have to write the changed xmin to disk *before* we change
* ->effective_xmin once the new state is synced to disk. After a
* crash ->effective_xmin is set to ->xmin.
*/
- if (TransactionIdIsValid(slot->candidate_catalog_xmin) &&
- slot->data.catalog_xmin != slot->candidate_catalog_xmin)
+ if (TransactionIdIsValid(MyReplicationSlot->candidate_catalog_xmin) &&
+ MyReplicationSlot->data.catalog_xmin != MyReplicationSlot->candidate_catalog_xmin)
{
- slot->data.catalog_xmin = slot->candidate_catalog_xmin;
- slot->candidate_catalog_xmin = InvalidTransactionId;
- slot->candidate_xmin_lsn = InvalidXLogRecPtr;
+ MyReplicationSlot->data.catalog_xmin = MyReplicationSlot->candidate_catalog_xmin;
+ MyReplicationSlot->candidate_catalog_xmin = InvalidTransactionId;
+ MyReplicationSlot->candidate_xmin_lsn = InvalidXLogRecPtr;
updated_xmin = true;
}
}
- if (slot->candidate_restart_valid != InvalidXLogRecPtr &&
- slot->candidate_restart_valid <= lsn)
+ if (MyReplicationSlot->candidate_restart_valid != InvalidXLogRecPtr &&
+ MyReplicationSlot->candidate_restart_valid <= lsn)
{
- Assert(slot->candidate_restart_lsn != InvalidXLogRecPtr);
+ Assert(MyReplicationSlot->candidate_restart_lsn != InvalidXLogRecPtr);
- slot->data.restart_lsn = slot->candidate_restart_lsn;
- slot->candidate_restart_lsn = InvalidXLogRecPtr;
- slot->candidate_restart_valid = InvalidXLogRecPtr;
+ MyReplicationSlot->data.restart_lsn = MyReplicationSlot->candidate_restart_lsn;
+ MyReplicationSlot->candidate_restart_lsn = InvalidXLogRecPtr;
+ MyReplicationSlot->candidate_restart_valid = InvalidXLogRecPtr;
updated_restart = true;
}
- SpinLockRelease(&slot->mutex);
+ SpinLockRelease(&MyReplicationSlot->mutex);
/* first write new xmin to disk, so we know whats up after a crash */
if (updated_xmin || updated_restart)
*/
if (updated_xmin)
{
- SpinLockAcquire(&slot->mutex);
- slot->effective_catalog_xmin = slot->data.catalog_xmin;
- SpinLockRelease(&slot->mutex);
+ SpinLockAcquire(&MyReplicationSlot->mutex);
+ MyReplicationSlot->effective_catalog_xmin = MyReplicationSlot->data.catalog_xmin;
+ SpinLockRelease(&MyReplicationSlot->mutex);
ReplicationSlotsComputeRequiredXmin(false);
ReplicationSlotsComputeRequiredLSN();
}
else
{
- volatile ReplicationSlot *slot = MyReplicationSlot;
-
- SpinLockAcquire(&slot->mutex);
- slot->data.confirmed_flush = lsn;
- SpinLockRelease(&slot->mutex);
+ SpinLockAcquire(&MyReplicationSlot->mutex);
+ MyReplicationSlot->data.confirmed_flush = lsn;
+ SpinLockRelease(&MyReplicationSlot->mutex);
}
}
slot->in_use = true;
/* We can now mark the slot active, and that makes it our slot. */
- {
- volatile ReplicationSlot *vslot = slot;
-
- SpinLockAcquire(&slot->mutex);
- Assert(vslot->active_pid == 0);
- vslot->active_pid = MyProcPid;
- SpinLockRelease(&slot->mutex);
- MyReplicationSlot = slot;
- }
+ SpinLockAcquire(&slot->mutex);
+ Assert(slot->active_pid == 0);
+ slot->active_pid = MyProcPid;
+ SpinLockRelease(&slot->mutex);
+ MyReplicationSlot = slot;
LWLockRelease(ReplicationSlotControlLock);
if (s->in_use && strcmp(name, NameStr(s->data.name)) == 0)
{
- volatile ReplicationSlot *vslot = s;
-
SpinLockAcquire(&s->mutex);
- active_pid = vslot->active_pid;
+ active_pid = s->active_pid;
if (active_pid == 0)
- vslot->active_pid = MyProcPid;
+ s->active_pid = MyProcPid;
SpinLockRelease(&s->mutex);
slot = s;
break;
else
{
/* Mark slot inactive. We're not freeing it, just disconnecting. */
- volatile ReplicationSlot *vslot = slot;
-
SpinLockAcquire(&slot->mutex);
- vslot->active_pid = 0;
+ slot->active_pid = 0;
SpinLockRelease(&slot->mutex);
}
}
else
{
- volatile ReplicationSlot *vslot = slot;
bool fail_softly = slot->data.persistency == RS_EPHEMERAL;
SpinLockAcquire(&slot->mutex);
- vslot->active_pid = 0;
+ slot->active_pid = 0;
SpinLockRelease(&slot->mutex);
ereport(fail_softly ? WARNING : ERROR,
void
ReplicationSlotMarkDirty(void)
{
+ ReplicationSlot *slot = MyReplicationSlot;
Assert(MyReplicationSlot != NULL);
- {
- volatile ReplicationSlot *vslot = MyReplicationSlot;
-
- SpinLockAcquire(&vslot->mutex);
- MyReplicationSlot->just_dirtied = true;
- MyReplicationSlot->dirty = true;
- SpinLockRelease(&vslot->mutex);
- }
+ SpinLockAcquire(&slot->mutex);
+ MyReplicationSlot->just_dirtied = true;
+ MyReplicationSlot->dirty = true;
+ SpinLockRelease(&slot->mutex);
}
/*
Assert(slot != NULL);
Assert(slot->data.persistency != RS_PERSISTENT);
- {
- volatile ReplicationSlot *vslot = slot;
-
- SpinLockAcquire(&slot->mutex);
- vslot->data.persistency = RS_PERSISTENT;
- SpinLockRelease(&slot->mutex);
- }
+ SpinLockAcquire(&slot->mutex);
+ slot->data.persistency = RS_PERSISTENT;
+ SpinLockRelease(&slot->mutex);
ReplicationSlotMarkDirty();
ReplicationSlotSave();
if (!s->in_use)
continue;
- {
- volatile ReplicationSlot *vslot = s;
-
- SpinLockAcquire(&s->mutex);
- effective_xmin = vslot->effective_xmin;
- effective_catalog_xmin = vslot->effective_catalog_xmin;
- SpinLockRelease(&s->mutex);
- }
+ SpinLockAcquire(&s->mutex);
+ effective_xmin = s->effective_xmin;
+ effective_catalog_xmin = s->effective_catalog_xmin;
+ SpinLockRelease(&s->mutex);
/* check the data xmin */
if (TransactionIdIsValid(effective_xmin) &&
if (!s->in_use)
continue;
- {
- volatile ReplicationSlot *vslot = s;
-
- SpinLockAcquire(&s->mutex);
- restart_lsn = vslot->data.restart_lsn;
- SpinLockRelease(&s->mutex);
- }
+ SpinLockAcquire(&s->mutex);
+ restart_lsn = s->data.restart_lsn;
+ SpinLockRelease(&s->mutex);
if (restart_lsn != InvalidXLogRecPtr &&
(min_required == InvalidXLogRecPtr ||
for (i = 0; i < max_replication_slots; i++)
{
- volatile ReplicationSlot *s;
+ ReplicationSlot *s;
XLogRecPtr restart_lsn;
s = &ReplicationSlotCtl->replication_slots[i];
LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
for (i = 0; i < max_replication_slots; i++)
{
- volatile ReplicationSlot *s;
+ ReplicationSlot *s;
s = &ReplicationSlotCtl->replication_slots[i];
bool was_dirty;
/* first check whether there's something to write out */
- {
- volatile ReplicationSlot *vslot = slot;
-
- SpinLockAcquire(&vslot->mutex);
- was_dirty = vslot->dirty;
- vslot->just_dirtied = false;
- SpinLockRelease(&vslot->mutex);
- }
+ SpinLockAcquire(&slot->mutex);
+ was_dirty = slot->dirty;
+ slot->just_dirtied = false;
+ SpinLockRelease(&slot->mutex);
/* and don't do anything if there's nothing to write */
if (!was_dirty)
* Successfully wrote, unset dirty bit, unless somebody dirtied again
* already.
*/
- {
- volatile ReplicationSlot *vslot = slot;
-
- SpinLockAcquire(&vslot->mutex);
- if (!vslot->just_dirtied)
- vslot->dirty = false;
- SpinLockRelease(&vslot->mutex);
- }
+ SpinLockAcquire(&slot->mutex);
+ if (!slot->just_dirtied)
+ slot->dirty = false;
+ SpinLockRelease(&slot->mutex);
LWLockRelease(slot->io_in_progress_lock);
}
TimeLineID startpointTLI;
TimeLineID primaryTLI;
bool first_stream;
-
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
TimestampTz last_recv_timestamp;
bool ping_sent;
static void
WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
int state;
SpinLockAcquire(&walrcv->mutex);
static void
WalRcvDie(int code, Datum arg)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
/* Ensure that all WAL records received are flushed to disk */
XLogWalRcvFlush(true);
{
if (LogstreamResult.Flush < LogstreamResult.Write)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
issue_xlog_fsync(recvFile, recvSegNo);
static void
ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
TimestampTz lastMsgReceiptTime = GetCurrentTimestamp();
bool
WalRcvRunning(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
WalRcvState state;
pg_time_t startTime;
bool
WalRcvStreaming(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
WalRcvState state;
pg_time_t startTime;
void
ShutdownWalRcv(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
pid_t walrcvpid = 0;
/*
RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
const char *slotname)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
bool launch = false;
pg_time_t now = (pg_time_t) time(NULL);
XLogRecPtr
GetWalRcvWriteRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
XLogRecPtr recptr;
SpinLockAcquire(&walrcv->mutex);
int
GetReplicationApplyDelay(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
-
+ WalRcvData *walrcv = WalRcv;
XLogRecPtr receivePtr;
XLogRecPtr replayPtr;
int
GetReplicationTransferLatency(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalRcvData *walrcv = WalRcv;
+ WalRcvData *walrcv = WalRcv;
TimestampTz lastMsgSendTime;
TimestampTz lastMsgReceiptTime;
/* Initialize shared memory status, too */
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->sentPtr = sentPtr;
/* Also update the sent position status in shared memory */
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->sentPtr = MyReplicationSlot->data.restart_lsn;
PhysicalConfirmReceivedLocation(XLogRecPtr lsn)
{
bool changed = false;
-
- /* use volatile pointer to prevent code rearrangement */
- volatile ReplicationSlot *slot = MyReplicationSlot;
+ ReplicationSlot *slot = MyReplicationSlot;
Assert(lsn != InvalidXLogRecPtr);
SpinLockAcquire(&slot->mutex);
* standby.
*/
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->write = writePtr;
PhysicalReplicationSlotNewXmin(TransactionId feedbackXmin)
{
bool changed = false;
- volatile ReplicationSlot *slot = MyReplicationSlot;
+ ReplicationSlot *slot = MyReplicationSlot;
SpinLockAcquire(&slot->mutex);
MyPgXact->xmin = InvalidTransactionId;
*/
for (i = 0; i < max_wal_senders; i++)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = &WalSndCtl->walsnds[i];
+ WalSnd *walsnd = &WalSndCtl->walsnds[i];
SpinLockAcquire(&walsnd->mutex);
*/
if (am_cascading_walsender)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
bool reload;
SpinLockAcquire(&walsnd->mutex);
/* Update shared memory status */
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->sentPtr = sentPtr;
/* Update shared memory status */
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->sentPtr = sentPtr;
for (i = 0; i < max_wal_senders; i++)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = &WalSndCtl->walsnds[i];
+ WalSnd *walsnd = &WalSndCtl->walsnds[i];
if (walsnd->pid == 0)
continue;
void
WalSndSetState(WalSndState state)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = MyWalSnd;
+ WalSnd *walsnd = MyWalSnd;
Assert(am_walsender);
for (i = 0; i < max_wal_senders; i++)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = &WalSndCtl->walsnds[i];
+ WalSnd *walsnd = &WalSndCtl->walsnds[i];
XLogRecPtr sentPtr;
XLogRecPtr write;
XLogRecPtr flush;
for (i = 0; i < max_wal_senders; i++)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile WalSnd *walsnd = &WalSndCtl->walsnds[i];
+ WalSnd *walsnd = &WalSndCtl->walsnds[i];
XLogRecPtr recptr;
if (walsnd->pid == 0)