update LsnNode struct location

Signed-off-by: shipixian <shipixian_yewu@cmss.chinamobile.com>
This commit is contained in:
shipixian 2023-03-24 16:55:05 +08:00
parent cd1868117c
commit 134162fa58
4 changed files with 32 additions and 22 deletions

View File

@ -2378,28 +2378,30 @@ He3DBFileRead(File file, char **buffer, off_t offset,
{
//TODO 如果本地盘不存在则调用标准接口读取page再调用tikv的借口获取范围的wal
uint8_t *buf = (uint8_t *)malloc(BLCKSZ);
Bufrd result;
FileRead(file,buf,BLCKSZ,offset,wait_event_info);
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;
}
}

View File

@ -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;

View File

@ -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);
@ -69,9 +71,8 @@ extern Bufrd ReadWalsByPage(uint32_t dbid,
uint32_t relid,
uint32_t forkno,
uint32_t blkno,
uint64_t startlsn,
uint64_t endlsn,
uint32_t timeline);
uint32_t timeline,
LsnNode* lsnhead);

View File

@ -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 */