!868 Revert logical of block exist in smgr/md level
Merge pull request !868 from LiHeng/master
This commit is contained in:
@ -3149,7 +3149,7 @@
|
||||
),
|
||||
AddFuncGroup(
|
||||
"global_comm_get_status", 1,
|
||||
AddBuiltinFunc(_0(1990), _1("global_comm_get_status"), _2(0), _3(true), _4(true), _5(global_comm_get_status), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1000), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(13, 25, 23, 23, 20, 20, 20, 20, 20, 23, 23, 23, 23, 23), _22(13, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(13, "node_name", "rxpck_rate", "txpck_rate", "rxkb_rate", "txkb_rate", "buffer", "memkb_libcomm", "memkb_libpq", "used_pm", "used_sflow", "used_rflow", "used_rloop", "stream"), _24(NULL), _25("global_comm_get_status"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
|
||||
AddBuiltinFunc(_0(1990), _1("global_comm_get_status"), _2(0), _3(true), _4(true), _5(global_comm_get_status), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1000), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(13, 25, 23, 23, 20, 20, 20, 20, 20, 23, 23, 23, 23, 23), _22(13, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(13, "node_name", "rxpck_rate", "txpck_rate", "rxkB_rate", "txkB_rate", "buffer", "memKB_libcomm", "memKB_libpq", "used_PM", "used_sflow", "used_rflow", "used_rloop", "stream"), _24(NULL), _25("global_comm_get_status"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("f"))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"global_stat_clean_hotkeys", 1,
|
||||
@ -6662,7 +6662,7 @@
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_comm_status", 1,
|
||||
AddBuiltinFunc(_0(1986), _1("pg_comm_status"), _2(0), _3(true), _4(true), _5(pg_comm_status), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1000), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(13, 25, 23, 23, 20, 20, 20, 20, 20, 23, 23, 23, 23, 23), _22(13, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(13, "node_name", "rxpck_rate", "txpck_rate", "rxkb_rate", "txkb_rate", "buffer", "memkb_libcomm", "memkb_libpq", "used_pm", "used_sflow", "used_rflow", "used_rloop", "stream"), _24(NULL), _25("pg_comm_status"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
|
||||
AddBuiltinFunc(_0(1986), _1("pg_comm_status"), _2(0), _3(true), _4(true), _5(pg_comm_status), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1000), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(13, 25, 23, 23, 20, 20, 20, 20, 20, 23, 23, 23, 23, 23), _22(13, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(13, "node_name", "rxpck_rate", "txpck_rate", "rxkB_rate", "txkB_rate", "buffer", "memKB_libcomm", "memKB_libpq", "used_PM", "used_sflow", "used_rflow", "used_rloop", "stream"), _24(NULL), _25("pg_comm_status"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("f"))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_conf_load_time", 1,
|
||||
@ -6771,7 +6771,7 @@
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_export_snapshot_and_csn", 1,
|
||||
AddBuiltinFunc(_0(4396), _1("pg_export_snapshot_and_csn"), _2(0), _3(true), _4(false), _5(pg_export_snapshot_and_csn), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(2, 25, 25), _22(2, 'o', 'o'), _23(2, "snapshot", "csn"), _24(NULL), _25("pg_export_snapshot_and_csn"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
|
||||
AddBuiltinFunc(_0(4396), _1("pg_export_snapshot_and_csn"), _2(0), _3(true), _4(false), _5(pg_export_snapshot_and_csn), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(2, 25, 25), _22(2, 'o', 'o'), _23(2, "snapshot", "CSN"), _24(NULL), _25("pg_export_snapshot_and_csn"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_extension_config_dump", 1,
|
||||
@ -6876,7 +6876,7 @@
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_get_variable_info", 1,
|
||||
AddBuiltinFunc(_0(2097), _1("pg_get_variable_info"), _2(0), _3(true), _4(true), _5(pg_get_variable_info), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(11, 25, 26, 28, 28, 28, 26, 28, 28, 28, 28, 28), _22(11, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(11, "node_name", "next_oid", "next_xid", "oldest_xid", "xid_vac_limit", "oldest_xid_db", "last_extend_csn_logpage", "start_extend_csn_logpage", "next_commit_seqno", "latest_completed_xid", "startup_max_xid"), _24(NULL), _25("pg_get_variable_info"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
|
||||
AddBuiltinFunc(_0(2097), _1("pg_get_variable_info"), _2(0), _3(true), _4(true), _5(pg_get_variable_info), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(11, 25, 26, 28, 28, 28, 26, 28, 28, 28, 28, 28), _22(11, 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(11, "node_name", "nextOid", "nextXid", "oldestXid", "xidVacLimit", "oldestXidDB", "lastExtendCSNLogpage", "startExtendCSNLogpage", "nextCommitSeqNo", "latestCompletedXid", "startupMaxXid"), _24(NULL), _25("pg_get_variable_info"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("f"))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_get_viewdef", 5,
|
||||
@ -6888,7 +6888,7 @@
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_get_xidlimit", 1,
|
||||
AddBuiltinFunc(_0(2000), _1("pg_get_xidlimit"), _2(0), _3(true), _4(true), _5(pg_get_xidlimit), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1000), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(7, 28, 28, 28, 28, 28, 28, 26), _22(7, 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(7, "next_xid", "oldest_xid", "xid_vac_limit", "xid_warn_limit", "xid_stop_limit", "xid_wrap_limit", "oldest_xid_db"), _24(NULL), _25("pg_get_xidlimit"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
|
||||
AddBuiltinFunc(_0(2000), _1("pg_get_xidlimit"), _2(0), _3(true), _4(true), _5(pg_get_xidlimit), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1000), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(7, 28, 28, 28, 28, 28, 28, 26), _22(7, 'o', 'o', 'o', 'o', 'o', 'o', 'o'), _23(7, "nextXid", "oldestXid", "xidVacLimit", "xidWarnLimit", "xidStopLimit", "xidWrapLimit", "oldestXidDB"), _24(NULL), _25("pg_get_xidlimit"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("f"))
|
||||
),
|
||||
AddFuncGroup(
|
||||
"pg_gtt_attached_pid", 1,
|
||||
|
||||
@ -120,7 +120,7 @@ static void CheckForBufferLeaks(void);
|
||||
static int ts_ckpt_progress_comparator(Datum a, Datum b, void *arg);
|
||||
static bool ReadBuffer_common_ReadBlock(SMgrRelation smgr, char relpersistence,
|
||||
ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, bool isExtend,
|
||||
Block bufBlock, bool *blockExist);
|
||||
Block bufBlock);
|
||||
|
||||
/*
|
||||
* Return the PrivateRefCount entry for the passed buffer. It is searched
|
||||
@ -1753,6 +1753,22 @@ Buffer ReadBuffer_common_for_localbuf(RelFileNode rnode, char relpersistence, Fo
|
||||
blockNum = smgrnblocks(smgr, forkNum);
|
||||
}
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
/* When the parallel redo is enabled, there may be a scenario where
|
||||
* the index is replayed before the page replayed. For single-mode,
|
||||
* readable standby feature, Operators related to index scan access
|
||||
* the index first, then access the table, and you will find that
|
||||
* the tid or the heap(page) does not exist. Because the transaction
|
||||
* was not originally committed, the tid or the heap(page) should not
|
||||
* be visible. So accessing the non-existent heap tuple by the tid
|
||||
* should return that the tuple does not exist without error reporting.
|
||||
*/
|
||||
else if (RecoveryInProgress()) {
|
||||
if (blockNum >= smgrnblocks(smgr, forkNum))
|
||||
return InvalidBuffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
bufHdr = LocalBufferAlloc(smgr, forkNum, blockNum, &found);
|
||||
if (found) {
|
||||
u_sess->instr_cxt.pg_buffer_usage->local_blks_hit++;
|
||||
@ -1834,12 +1850,8 @@ Buffer ReadBuffer_common_for_localbuf(RelFileNode rnode, char relpersistence, Fo
|
||||
|
||||
bufBlock = LocalBufHdrGetBlock(bufHdr);
|
||||
|
||||
bool block_exist = true;
|
||||
(void)ReadBuffer_common_ReadBlock(smgr, relpersistence, forkNum, blockNum, mode,
|
||||
isExtend, bufBlock, &block_exist);
|
||||
if (!block_exist && RecoveryInProgress()) {
|
||||
return InvalidBuffer;
|
||||
}
|
||||
isExtend, bufBlock);
|
||||
|
||||
uint32 buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||
buf_state |= BM_VALID;
|
||||
@ -1871,12 +1883,8 @@ Buffer ReadBuffer_common_for_direct(RelFileNode rnode, char relpersistence, Fork
|
||||
XLogRedoBufferGetBlkFunc(bufferslot, &bufBlock);
|
||||
|
||||
Assert(bufBlock != NULL);
|
||||
bool block_exist = true;
|
||||
(void)ReadBuffer_common_ReadBlock(smgr, relpersistence, forkNum, blockNum, mode,
|
||||
isExtend, bufBlock, &block_exist);
|
||||
if (!block_exist && RecoveryInProgress()) {
|
||||
return InvalidBuffer;
|
||||
}
|
||||
isExtend, bufBlock);
|
||||
XLogRedoBufferSetStateFunc(bufferslot, BM_VALID);
|
||||
return RedoBufferSlotGetBuffer(bufferslot);
|
||||
}
|
||||
@ -1887,7 +1895,7 @@ Buffer ReadBuffer_common_for_direct(RelFileNode rnode, char relpersistence, Fork
|
||||
* * 2020-03-05
|
||||
*/
|
||||
static bool ReadBuffer_common_ReadBlock(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
||||
BlockNumber blockNum, ReadBufferMode mode, bool isExtend, Block bufBlock, bool *blockExist)
|
||||
BlockNumber blockNum, ReadBufferMode mode, bool isExtend, Block bufBlock)
|
||||
{
|
||||
bool needputtodirty = false;
|
||||
|
||||
@ -1932,7 +1940,7 @@ static bool ReadBuffer_common_ReadBlock(SMgrRelation smgr, char relpersistence,
|
||||
|
||||
INSTR_TIME_SET_CURRENT(io_start);
|
||||
|
||||
*blockExist = smgrread(smgr, forkNum, blockNum, (char*)bufBlock);
|
||||
smgrread(smgr, forkNum, blockNum, (char*)bufBlock);
|
||||
|
||||
if (u_sess->attr.attr_common.track_io_timing) {
|
||||
INSTR_TIME_SET_CURRENT(io_time);
|
||||
@ -1946,13 +1954,6 @@ static bool ReadBuffer_common_ReadBlock(SMgrRelation smgr, char relpersistence,
|
||||
pgstatCountBlocksReadTime4SessionLevel(INSTR_TIME_GET_MICROSEC(io_time));
|
||||
}
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
/* Block not exists */
|
||||
if (!(*blockExist) && RecoveryInProgress()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* check for garbage data */
|
||||
if (!PageIsVerified((Page)bufBlock, blockNum)) {
|
||||
addBadBlockStat(&smgr->smgr_rnode.node, forkNum);
|
||||
@ -2162,21 +2163,7 @@ static Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumb
|
||||
|
||||
bool block_exist = true;
|
||||
bool needputtodirty = ReadBuffer_common_ReadBlock(smgr, relpersistence, forkNum, blockNum,
|
||||
mode, isExtend, bufBlock, &block_exist);
|
||||
/*
|
||||
* When the parallel redo is enabled, there may be a scenario where
|
||||
* the index is replayed before the page replayed. For single-mode,
|
||||
* readable standby feature, Operators related to index scan access
|
||||
* the index first, then access the table, and you will find that
|
||||
* the tid or the heap(page) does not exist. Because the transaction
|
||||
* was not originally committed, the tid or the heap(page) should not
|
||||
* be visible. So accessing the non-existent heap tuple by the tid
|
||||
* should return that the tuple does not exist without error reporting.
|
||||
*/
|
||||
if (!block_exist && RecoveryInProgress()) {
|
||||
return InvalidBuffer;
|
||||
}
|
||||
|
||||
mode, isExtend, bufBlock);
|
||||
if (needputtodirty) {
|
||||
/* set BM_DIRTY to overwrite later */
|
||||
uint32 old_buf_state = LockBufHdr(bufHdr);
|
||||
|
||||
@ -990,7 +990,7 @@ static void check_file_stat(char *file_name)
|
||||
* mdread() -- Read the specified block from a relation.
|
||||
* Now, we don't read from a bucket dir smgr.
|
||||
*/
|
||||
bool mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer)
|
||||
void mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
off_t seekpos;
|
||||
int nbytes;
|
||||
@ -1076,11 +1076,6 @@ bool mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *b
|
||||
|
||||
if (nbytes != BLCKSZ) {
|
||||
if (nbytes < 0) {
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
if(RecoveryInProgress()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
ereport(ERROR, (errcode_for_file_access(),
|
||||
errmsg("could not read block %u in file \"%s\": %m", blocknum, FilePathName(v->mdfd_vfd))));
|
||||
}
|
||||
@ -1098,19 +1093,11 @@ bool mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *b
|
||||
check_file_stat(FilePathName(v->mdfd_vfd));
|
||||
force_backtrace_messages = true;
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
if(RecoveryInProgress()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg("could not read block %u in file \"%s\": read only %d of %d bytes", blocknum,
|
||||
FilePathName(v->mdfd_vfd), nbytes, BLCKSZ)));
|
||||
}
|
||||
}
|
||||
|
||||
/* Target block exists */
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -50,7 +50,7 @@ typedef struct f_smgr {
|
||||
void (*smgr_extend)(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const char *buffer,
|
||||
bool skipFsync);
|
||||
void (*smgr_prefetch)(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum);
|
||||
bool (*smgr_read)(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer);
|
||||
void (*smgr_read)(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer);
|
||||
void (*smgr_write)(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const char *buffer, bool skipFsync);
|
||||
void (*smgr_writeback)(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, BlockNumber nblocks);
|
||||
BlockNumber (*smgr_nblocks)(SMgrRelation reln, ForkNumber forknum);
|
||||
@ -769,9 +769,9 @@ void smgrasyncwrite(SMgrRelation reln, ForkNumber forknum, AioDispatchDesc_t **d
|
||||
* instantiate pages in the shared buffer cache. All storage managers
|
||||
* return pages in the format that POSTGRES expects.
|
||||
*/
|
||||
bool smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer)
|
||||
void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer)
|
||||
{
|
||||
return (*(smgrsw[reln->smgr_which].smgr_read))(reln, forknum, blocknum, buffer);
|
||||
(*(smgrsw[reln->smgr_which].smgr_read))(reln, forknum, blocknum, buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -102,7 +102,7 @@ extern void smgrdounlink(SMgrRelation reln, bool isRedo);
|
||||
extern void smgrdounlinkfork(SMgrRelation reln, ForkNumber forknum, bool isRedo);
|
||||
extern void smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const char* buffer, bool skipFsync);
|
||||
extern void smgrprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum);
|
||||
extern bool smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer);
|
||||
extern void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer);
|
||||
extern void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const char* buffer, bool skipFsync);
|
||||
extern void smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, BlockNumber nblocks);
|
||||
extern BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum);
|
||||
@ -127,7 +127,7 @@ extern bool mdexists(SMgrRelation reln, ForkNumber forknum);
|
||||
extern void mdunlink(const RelFileNodeBackend& rnode, ForkNumber forknum, bool isRedo);
|
||||
extern void mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const char* buffer, bool skipFsync);
|
||||
extern void mdprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum);
|
||||
extern bool mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer);
|
||||
extern void mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char* buffer);
|
||||
extern void mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const char* buffer, bool skipFsync);
|
||||
extern void mdwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, BlockNumber nblocks);
|
||||
extern BlockNumber mdnblocks(SMgrRelation reln, ForkNumber forknum);
|
||||
|
||||
Reference in New Issue
Block a user