mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-03 12:47:34 +08:00
localdisk only have page in pushstandby
Signed-off-by: shipixian <shipixian_yewu@cmss.chinamobile.com>
This commit is contained in:
parent
12f12cfbfc
commit
76278e8dc3
@ -97,6 +97,7 @@
|
||||
#include "pgstat.h"
|
||||
#include "port/pg_iovec.h"
|
||||
#include "portability/mem.h"
|
||||
#include "storage/buf_internals.h"
|
||||
#include "storage/fd.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/spin.h"
|
||||
@ -2350,18 +2351,18 @@ FileWriteback(File file, off_t offset, off_t nbytes, uint32 wait_event_info)
|
||||
|
||||
int
|
||||
He3DBFileRead(File file, char **buffer, off_t offset,
|
||||
uint32 wait_event_info, XLogRecPtr lsn,
|
||||
uint32_t dbid, uint32_t relid, uint32_t segno, uint32_t forkno)
|
||||
uint32 wait_event_info, XLogRecPtr lsn,
|
||||
BufferTag pageTag)
|
||||
{
|
||||
//TODO 先从本地盘读取数据,如果存在则返回
|
||||
PageKey pageKey;
|
||||
Bufrd bufrd;
|
||||
bufrd.count = 0;
|
||||
|
||||
pageKey.relfileNode.dbNode = dbid;
|
||||
pageKey.relfileNode.relNode = relid;
|
||||
pageKey.forkNo = forkno;
|
||||
pageKey.blkNo = (offset >>13) + segno * (1 << 17);
|
||||
pageKey.relfileNode.dbNode = pageTag.rnode.dbNode;
|
||||
pageKey.relfileNode.relNode = pageTag.rnode.relNode;
|
||||
pageKey.forkNo = pageTag.forkNum;
|
||||
pageKey.blkNo = pageTag.blockNum;
|
||||
pageKey.pageLsn = 0;
|
||||
pageKey.replyLsn = lsn;
|
||||
|
||||
@ -2370,6 +2371,20 @@ He3DBFileRead(File file, char **buffer, off_t offset,
|
||||
{
|
||||
*buffer = (uint8_t *)malloc(bufrd.count);
|
||||
memcpy(buffer, bufrd.buf,bufrd.count);
|
||||
|
||||
if (push_standby)
|
||||
{
|
||||
Assert(bufrd.count == BLCKSZ);
|
||||
pageKey.pageLsn = PageGetLSN(bufrd.buf);
|
||||
LsnNode *head = GetLogIndexByPage(&pageTag, pageKey.pageLsn, pageKey.replyLsn);
|
||||
Bufrd result;
|
||||
result = ReadWalsByPage(pageKey.relfileNode.dbNode, pageKey.relfileNode.relNode,
|
||||
pageKey.forkNo, pageKey.blkNo, ThisTimeLineID, head);
|
||||
buffer = (uint8_t *)realloc(buffer, BLCKSZ + result.count);
|
||||
strcat(buffer,result.buf);
|
||||
//TODO free result
|
||||
free_dataRead(result.buf, result.count, result.cap);
|
||||
}
|
||||
free_dataRead(bufrd.buf, bufrd.count, bufrd.cap);
|
||||
// *buffer = bufrd.buf;
|
||||
return bufrd.count;
|
||||
@ -2384,7 +2399,7 @@ He3DBFileRead(File file, char **buffer, off_t offset,
|
||||
pageKey.pageLsn = PageGetLSN(buf);;
|
||||
pageKey.replyLsn = lsn;
|
||||
|
||||
LsnNode *head = GetLogIndexByPage(buf, pageKey.pageLsn, pageKey.replyLsn);
|
||||
LsnNode *head = GetLogIndexByPage(&pageTag, pageKey.pageLsn, pageKey.replyLsn);
|
||||
if (head->next != NULL)
|
||||
{
|
||||
Bufrd result;
|
||||
|
@ -742,6 +742,11 @@ he3db_mdread_pagexlog(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknu
|
||||
MdfdVec *v;
|
||||
uint32_t segno;
|
||||
|
||||
BufferTag pageTag;
|
||||
pageTag.rnode = reln->smgr_rnode.node;
|
||||
pageTag.forkNum = forknum;
|
||||
pageTag.blockNum = blocknum;
|
||||
|
||||
TRACE_POSTGRESQL_SMGR_MD_READ_START(forknum, blocknum,
|
||||
reln->smgr_rnode.node.spcNode,
|
||||
reln->smgr_rnode.node.dbNode,
|
||||
@ -756,7 +761,7 @@ he3db_mdread_pagexlog(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknu
|
||||
Assert(seekpos < (off_t) BLCKSZ * RELSEG_SIZE);
|
||||
segno = (uint32_t)blocknum /((BlockNumber) RELSEG_SIZE);
|
||||
|
||||
nbytes = He3DBFileRead(v->mdfd_vfd, buffer, seekpos, WAIT_EVENT_DATA_FILE_READ, lsn, reln->smgr_rnode.node.dbNode, reln->smgr_rnode.node.relNode,segno, forknum);
|
||||
nbytes = He3DBFileRead(v->mdfd_vfd, buffer, seekpos, WAIT_EVENT_DATA_FILE_READ, lsn, pageTag);
|
||||
|
||||
TRACE_POSTGRESQL_SMGR_MD_READ_DONE(forknum, blocknum,
|
||||
reln->smgr_rnode.node.spcNode,
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include <dirent.h>
|
||||
#include "access/xlogdefs.h"
|
||||
#include "storage/buf_internals.h"
|
||||
|
||||
typedef enum RecoveryInitSyncMethod
|
||||
{
|
||||
@ -95,7 +96,7 @@ extern void FileClose(File file);
|
||||
extern int FilePrefetch(File file, off_t offset, int amount, uint32 wait_event_info);
|
||||
extern int FileRead(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info);
|
||||
extern int MasterFileRead(char *buffer, uint32_t dbid, uint32_t relid, uint32_t forkno, uint32_t blockno);
|
||||
extern int He3DBFileRead(File file, char **buffer, off_t offset, uint32 wait_event_info, XLogRecPtr lsn, uint32_t dbid, uint32_t relid, uint32_t segno, uint32_t forkno);
|
||||
extern int He3DBFileRead(File file, char **buffer, off_t offset, uint32 wait_event_info, XLogRecPtr lsn, BufferTag pageTag);
|
||||
extern int FileWrite(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info);
|
||||
extern int He3DBFileWrite(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info);
|
||||
extern int FileSync(File file, uint32 wait_event_info);
|
||||
|
Loading…
Reference in New Issue
Block a user