mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-03 12:47:34 +08:00
!87 fix bug when read block and update LsnNode struct location
Merge pull request !87 from shipixian/dev_performance
This commit is contained in:
commit
68ca25e61e
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
char *buffer)
|
||||
{
|
||||
off_t seekpos;
|
||||
int nbytes;
|
||||
int nbytes = 0;
|
||||
MdfdVec *v;
|
||||
uint32_t segno;
|
||||
|
||||
|
@ -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);
|
||||
@ -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);
|
||||
|
||||
|
||||
|
||||
|
@ -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