mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-02 04:07:34 +08:00
restart failed problem
Code Source From: Self Code Description: 【Optional】 Jira: #【Optional】 市场项目编号(名称):【Optional】
This commit is contained in:
parent
cba0c24fb2
commit
0ce8241f37
@ -398,7 +398,7 @@ pg_truncate_visibility_map(PG_FUNCTION_ARGS)
|
|||||||
if (BlockNumberIsValid(block))
|
if (BlockNumberIsValid(block))
|
||||||
{
|
{
|
||||||
fork = VISIBILITYMAP_FORKNUM;
|
fork = VISIBILITYMAP_FORKNUM;
|
||||||
smgrtruncate(rel->rd_smgr, &fork, 1, &block);
|
smgrtruncatelsn(rel->rd_smgr, &fork, 1, &block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RelationNeedsWAL(rel))
|
if (RelationNeedsWAL(rel))
|
||||||
@ -411,7 +411,10 @@ pg_truncate_visibility_map(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
XLogRegisterData((char *) &xlrec, sizeof(xlrec));
|
XLogRegisterData((char *) &xlrec, sizeof(xlrec));
|
||||||
|
if (IsBootstrapProcessingMode() != true && InitdbSingle != true) {
|
||||||
|
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT
|
||||||
|
| CHECKPOINT_FLUSH_ALL);
|
||||||
|
}
|
||||||
XLogInsert(RM_SMGR_ID, XLOG_SMGR_TRUNCATE | XLR_SPECIAL_REL_UPDATE);
|
XLogInsert(RM_SMGR_ID, XLOG_SMGR_TRUNCATE | XLR_SPECIAL_REL_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8054,7 +8054,6 @@ data_buffer_for_replay(XLogReaderState *record,XLogRecPtr startLsn,XLogRecPtr en
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
bool valid;
|
bool valid;
|
||||||
BufferDesc *buf;
|
BufferDesc *buf;
|
||||||
/* See if the block is in the buffer pool already */
|
|
||||||
//for pg master he3db slave or backup restore
|
//for pg master he3db slave or backup restore
|
||||||
SMgrRelation smgr = smgropen(rnode, InvalidBackendId);
|
SMgrRelation smgr = smgropen(rnode, InvalidBackendId);
|
||||||
smgrcreate(smgr, forknum, true);
|
smgrcreate(smgr, forknum, true);
|
||||||
@ -8070,6 +8069,7 @@ data_buffer_for_replay(XLogReaderState *record,XLogRecPtr startLsn,XLogRecPtr en
|
|||||||
} else {
|
} else {
|
||||||
elog(PANIC,"data_buffer_for_replay blockNum is P_NEW");
|
elog(PANIC,"data_buffer_for_replay blockNum is P_NEW");
|
||||||
}
|
}
|
||||||
|
/* See if the block is in the buffer pool already */
|
||||||
LWLockAcquire(partition_lock, LW_SHARED);
|
LWLockAcquire(partition_lock, LW_SHARED);
|
||||||
buf_id = BufTableLookup(&tag, hash);
|
buf_id = BufTableLookup(&tag, hash);
|
||||||
/* If page is in buffer, we can apply record, otherwise we do nothing */
|
/* If page is in buffer, we can apply record, otherwise we do nothing */
|
||||||
|
@ -350,7 +350,10 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
|
|||||||
|
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
XLogRegisterData((char *) &xlrec, sizeof(xlrec));
|
XLogRegisterData((char *) &xlrec, sizeof(xlrec));
|
||||||
|
if (IsBootstrapProcessingMode() != true && InitdbSingle != true) {
|
||||||
|
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT
|
||||||
|
| CHECKPOINT_FLUSH_ALL);
|
||||||
|
}
|
||||||
lsn = XLogInsert(RM_SMGR_ID,
|
lsn = XLogInsert(RM_SMGR_ID,
|
||||||
XLOG_SMGR_TRUNCATE | XLR_SPECIAL_REL_UPDATE);
|
XLOG_SMGR_TRUNCATE | XLR_SPECIAL_REL_UPDATE);
|
||||||
|
|
||||||
|
@ -1034,7 +1034,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
} while (!StartBufferIO(bufHdr, true));
|
} while (!StartBufferIO(bufHdr, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we have gotten to this point, we have allocated a buffer for the
|
* if we have gotten to this point, we have allocated a buffer for the
|
||||||
* page but its contents are not yet valid. IO_IN_PROGRESS is set for it,
|
* page but its contents are not yet valid. IO_IN_PROGRESS is set for it,
|
||||||
@ -1172,6 +1172,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bufHdr->pageIsVaild = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
smgrread(smgr, forkNum, blockNum, (char *) bufBlock);
|
smgrread(smgr, forkNum, blockNum, (char *) bufBlock);
|
||||||
@ -1476,8 +1477,12 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
* If we get here, previous attempts to read the buffer must
|
* If we get here, previous attempts to read the buffer must
|
||||||
* have failed ... but we shall bravely try again.
|
* have failed ... but we shall bravely try again.
|
||||||
*/
|
*/
|
||||||
|
if (buf->pageIsVaild == false) {
|
||||||
|
*exist = false;
|
||||||
|
} else {
|
||||||
|
*exist = true;
|
||||||
|
}
|
||||||
*foundPtr = false;
|
*foundPtr = false;
|
||||||
*exist = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1696,6 +1701,11 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
* If we get here, previous attempts to read the buffer
|
* If we get here, previous attempts to read the buffer
|
||||||
* must have failed ... but we shall bravely try again.
|
* must have failed ... but we shall bravely try again.
|
||||||
*/
|
*/
|
||||||
|
if (buf->pageIsVaild == false) {
|
||||||
|
*exist = false;
|
||||||
|
} else {
|
||||||
|
*exist = true;
|
||||||
|
}
|
||||||
*foundPtr = false;
|
*foundPtr = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1748,7 +1758,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
buf_state |= BM_TAG_VALID | BM_PERMANENT | BUF_USAGECOUNT_ONE;
|
buf_state |= BM_TAG_VALID | BM_PERMANENT | BUF_USAGECOUNT_ONE;
|
||||||
else
|
else
|
||||||
buf_state |= BM_TAG_VALID | BUF_USAGECOUNT_ONE;
|
buf_state |= BM_TAG_VALID | BUF_USAGECOUNT_ONE;
|
||||||
|
buf->pageIsVaild = false;
|
||||||
UnlockBufHdr(buf, buf_state);
|
UnlockBufHdr(buf, buf_state);
|
||||||
|
|
||||||
if (oldPartitionLock != NULL)
|
if (oldPartitionLock != NULL)
|
||||||
@ -1766,8 +1776,14 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
* to read it before we did, so there's nothing left for BufferAlloc() to
|
* to read it before we did, so there's nothing left for BufferAlloc() to
|
||||||
* do.
|
* do.
|
||||||
*/
|
*/
|
||||||
if (StartBufferIO(buf, true))
|
if (StartBufferIO(buf, true)) {
|
||||||
|
if (buf->pageIsVaild == false) {
|
||||||
|
*exist = false;
|
||||||
|
} else {
|
||||||
|
*exist = true;
|
||||||
|
}
|
||||||
*foundPtr = false;
|
*foundPtr = false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*foundPtr = true;
|
*foundPtr = true;
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
* Note: BM_TAG_VALID essentially means that there is a buffer hashtable
|
* Note: BM_TAG_VALID essentially means that there is a buffer hashtable
|
||||||
* entry associated with the buffer's tag.
|
* entry associated with the buffer's tag.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BM_LOCKED (1U << 22) /* buffer header is locked */
|
#define BM_LOCKED (1U << 22) /* buffer header is locked */
|
||||||
#define BM_DIRTY (1U << 23) /* data needs writing */
|
#define BM_DIRTY (1U << 23) /* data needs writing */
|
||||||
#define BM_VALID (1U << 24) /* data is valid */
|
#define BM_VALID (1U << 24) /* data is valid */
|
||||||
@ -197,6 +198,7 @@ typedef struct BufferDesc
|
|||||||
int wait_backend_pid; /* backend PID of pin-count waiter */
|
int wait_backend_pid; /* backend PID of pin-count waiter */
|
||||||
int freeNext; /* link in freelist chain */
|
int freeNext; /* link in freelist chain */
|
||||||
LWLock content_lock; /* to lock access to buffer contents */
|
LWLock content_lock; /* to lock access to buffer contents */
|
||||||
|
bool pageIsVaild;
|
||||||
} BufferDesc;
|
} BufferDesc;
|
||||||
extern BufferDesc **bulk_io_in_progress_buf;
|
extern BufferDesc **bulk_io_in_progress_buf;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user