mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-02 04:07:34 +08:00
Merge branch 'dev_performance' of gitee.com:he3db/he3pg into dev_performance
This commit is contained in:
commit
7311b84fd9
@ -178,7 +178,7 @@ blbuildempty(Relation index)
|
||||
*/
|
||||
PageSetChecksumInplace(metapage, BLOOM_METAPAGE_BLKNO);
|
||||
smgrwrite(index->rd_smgr, INIT_FORKNUM, BLOOM_METAPAGE_BLKNO,
|
||||
(char *) metapage, true);
|
||||
(char *) metapage, true, PageGetLSN(metapage));
|
||||
log_newpage(&index->rd_smgr->smgr_rnode.node, INIT_FORKNUM,
|
||||
BLOOM_METAPAGE_BLKNO, metapage, true);
|
||||
|
||||
|
@ -2378,39 +2378,30 @@ He3DBFileRead(File file, char **buffer, off_t offset,
|
||||
{
|
||||
//TODO 如果本地盘不存在,则调用标准接口读取page,再调用tikv的借口获取范围的wal
|
||||
uint8_t *buf = (uint8_t *)malloc(BLCKSZ);
|
||||
Bufrd result;
|
||||
uint64 pageLSN = 0;
|
||||
|
||||
|
||||
FileRead(file,buf,BLCKSZ,offset,wait_event_info);
|
||||
|
||||
pageLSN = buf[0] |
|
||||
(buf[1] << 8) |
|
||||
(buf[2] << 16) |
|
||||
(buf[3] << 24) |
|
||||
(buf[4] << 32) |
|
||||
(buf[5] << 40) |
|
||||
(buf[6] << 48) |
|
||||
(buf[7] << 56);
|
||||
|
||||
pageKey.pageLsn = pageLSN;
|
||||
|
||||
pageKey.pageLsn = PageGetLSN(buf);;
|
||||
pageKey.replyLsn = lsn;
|
||||
|
||||
result = GetWalsFromDisk(pageKey);
|
||||
if (result.count == 0) {
|
||||
result = ReadWalsByPage(pageKey.relfileNode.dbNode,pageKey.relfileNode.relNode,
|
||||
pageKey.forkNo,pageKey.blkNo,pageKey.pageLsn,pageKey.replyLsn,0);
|
||||
LsnNode *head = GetLogIndexByPage(buf, pageKey.pageLsn, pageKey.replyLsn);
|
||||
if (head->next != NULL)
|
||||
{
|
||||
Bufrd result;
|
||||
result = GetWalsFromDisk(pageKey);
|
||||
if (result.count == 0) {
|
||||
result = ReadWalsByPage(pageKey.relfileNode.dbNode,pageKey.relfileNode.relNode,
|
||||
pageKey.forkNo,pageKey.blkNo, ThisTimeLineID, head);
|
||||
}
|
||||
|
||||
buf = (uint8_t *)realloc(buf, BLCKSZ + result.count);
|
||||
strcat(buf,result.buf);
|
||||
//TODO free result
|
||||
free_dataRead(result.buf, result.count, result.cap);
|
||||
*buffer = buf;
|
||||
return BLCKSZ + result.count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
buf = (uint8_t *)realloc(buf, BLCKSZ + result.count);
|
||||
strcat(buf,result.buf);
|
||||
//TODO free result
|
||||
free_dataRead(result.buf, result.count, result.cap);
|
||||
*buffer = buf;
|
||||
return BLCKSZ + result.count;
|
||||
return BLCKSZ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,7 +657,7 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
char *buffer)
|
||||
{
|
||||
off_t seekpos;
|
||||
int nbytes;
|
||||
int nbytes = 0;
|
||||
MdfdVec *v;
|
||||
uint32_t segno;
|
||||
|
||||
@ -676,7 +676,8 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
Assert(seekpos < (off_t) BLCKSZ * RELSEG_SIZE);
|
||||
|
||||
//TODO read page from disk
|
||||
nbytes = MasterFileRead(buffer,reln->smgr_rnode.node.dbNode,reln->smgr_rnode.node.relNode,forknum,blocknum);
|
||||
if (!(InitdbSingle || IsBootstrapProcessingMode() == true))
|
||||
nbytes = MasterFileRead(buffer,reln->smgr_rnode.node.dbNode,reln->smgr_rnode.node.relNode,forknum,blocknum);
|
||||
|
||||
if (nbytes == 0)
|
||||
{
|
||||
|
@ -558,25 +558,25 @@ void
|
||||
smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
char *buffer, bool skipFsync, XLogRecPtr lsn)
|
||||
{
|
||||
PageKey pageKey;
|
||||
pageKey.relfileNode.dbNode = reln->smgr_rnode.node.dbNode;
|
||||
pageKey.relfileNode.relNode = reln->smgr_rnode.node.relNode;
|
||||
pageKey.relfileNode.spcNode = reln->smgr_rnode.node.spcNode;
|
||||
if (!(InitdbSingle || IsBootstrapProcessingMode() == true)) {
|
||||
PageKey pageKey;
|
||||
pageKey.relfileNode.dbNode = reln->smgr_rnode.node.dbNode;
|
||||
pageKey.relfileNode.relNode = reln->smgr_rnode.node.relNode;
|
||||
pageKey.relfileNode.spcNode = reln->smgr_rnode.node.spcNode;
|
||||
|
||||
pageKey.blkNo = blocknum;
|
||||
pageKey.forkNo = forknum;
|
||||
pageKey.pageLsn = lsn;
|
||||
pageKey.blkNo = blocknum;
|
||||
pageKey.forkNo = forknum;
|
||||
pageKey.pageLsn = lsn;
|
||||
|
||||
//将page放到本地盘
|
||||
printf("write page key: dbid %ld, relid %ld, blkno %ld, forkno %ld, pagelsn %ld\n", pageKey.relfileNode.dbNode,
|
||||
pageKey.relfileNode.relNode, pageKey.blkNo, pageKey.forkNo, pageKey.pageLsn);
|
||||
EvictOnePageOutOfMemory(pageKey, buffer);
|
||||
|
||||
//if (push_standby == true || SmgrIsTemp(reln)) {
|
||||
// smgrsw[reln->smgr_which].smgr_write(reln, forknum, blocknum,
|
||||
// buffer, skipFsync);
|
||||
// elog(LOG,"smgrwrite reln %d,flk %d,blk %d",reln->smgr_rnode.node.relNode,forknum,blocknum);
|
||||
//}
|
||||
EvictOnePageOutOfMemory(pageKey, buffer);
|
||||
if (push_standby) {
|
||||
smgrsw[reln->smgr_which].smgr_write(reln, forknum, blocknum, buffer, skipFsync);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
smgrsw[reln->smgr_which].smgr_write(reln, forknum, blocknum, buffer, skipFsync);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "storage/shmem.h"
|
||||
#include "storage/s_lock.h"
|
||||
#include "storage/buf_internals.h"
|
||||
#include "utils/pg_lsn.h"
|
||||
|
||||
#define LOG_INDEX_MEM_ITEM_SEG_LSN_NUM 10
|
||||
#define LOG_INDEX_MEM_TBL_SEG_NUM 4096
|
||||
@ -89,10 +90,10 @@ typedef struct LogIndexMemList
|
||||
} LogIndexMemList;
|
||||
|
||||
// lsn listNode
|
||||
typedef struct LsnNode {
|
||||
XLogRecPtr lsn;
|
||||
struct LsnNode * next;
|
||||
} LsnNode;
|
||||
// typedef struct LsnNode {
|
||||
// XLogRecPtr lsn;
|
||||
// struct LsnNode * next;
|
||||
// } LsnNode;
|
||||
|
||||
typedef union He3DBBufTag{
|
||||
BufferTag tag;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "utils/pg_lsn.h"
|
||||
|
||||
typedef struct{
|
||||
uint8_t *buf;
|
||||
@ -40,6 +41,7 @@ typedef struct PageKey
|
||||
} PageKey;
|
||||
|
||||
|
||||
|
||||
extern IOResult openfs(const char *pathname, int flags);
|
||||
|
||||
extern int closefs(int64_t fd);
|
||||
@ -70,7 +72,7 @@ extern Bufrd ReadWalsByPage(uint32_t dbid,
|
||||
uint32_t forkno,
|
||||
uint32_t blkno,
|
||||
uint32_t timeline,
|
||||
LsnNode* head);
|
||||
LsnNode* lsnhead);
|
||||
extern void InsertConsistToKV(uint64_t lsn);
|
||||
extern uint64_t GetConsistLsn(uint64_t lsn);
|
||||
extern void DelConsistLsns(uint64_t lsn);
|
||||
|
@ -18,6 +18,11 @@
|
||||
#include "access/xlogdefs.h"
|
||||
#include "fmgr.h"
|
||||
|
||||
typedef struct LsnNode {
|
||||
XLogRecPtr lsn;
|
||||
struct LsnNode * next;
|
||||
} LsnNode;
|
||||
|
||||
#define DatumGetLSN(X) ((XLogRecPtr) DatumGetInt64(X))
|
||||
#define LSNGetDatum(X) (Int64GetDatum((int64) (X)))
|
||||
|
||||
@ -27,3 +32,4 @@
|
||||
extern XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error);
|
||||
|
||||
#endif /* PG_LSN_H */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user