mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-03 12:47:34 +08:00
parent
ebc7430aa4
commit
38a55cc693
@ -235,6 +235,17 @@ static void InsertLsnNodeByHead(LsnNode *head, XLogRecPtr lsn)
|
||||
head->next = new_node;
|
||||
}
|
||||
|
||||
// eg: before: head-->node1-->NULL, after: head-->node1-->newNode-->NULL
|
||||
static LsnNode *InsertLsnNodeByTail(LsnNode *head, int lsn)
|
||||
{
|
||||
LsnNode *new_node;
|
||||
new_node = (LsnNode *)malloc(sizeof(LsnNode));
|
||||
head->next = new_node;
|
||||
new_node->lsn = lsn;
|
||||
new_node->next = NULL;
|
||||
return new_node;
|
||||
}
|
||||
|
||||
// print nodelist
|
||||
static void PrintLsnNode(LsnNode *head)
|
||||
{
|
||||
@ -437,11 +448,13 @@ void InsertLogIndexByPage(const BufferTag *page, XLogRecPtr lsn)
|
||||
LsnNode *GetLogIndexByPage(const BufferTag *page, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
|
||||
{
|
||||
LsnNode *head_node;
|
||||
LsnNode *tail;
|
||||
uint64 tbl_index;
|
||||
|
||||
// Prevent metadata changes during discovery.
|
||||
// TODO change to Lightweight Lock
|
||||
head_node = InitLsnNode();
|
||||
tail = head_node;
|
||||
LWLockAcquire(LogIndexMemListLock,LW_SHARED);
|
||||
tbl_index = log_index_mem_list->table_start_index;
|
||||
while(tbl_index != log_index_mem_list->active_table_index)
|
||||
@ -470,9 +483,8 @@ LsnNode *GetLogIndexByPage(const BufferTag *page, XLogRecPtr start_lsn, XLogRecP
|
||||
{
|
||||
if(lsn < end_lsn)
|
||||
{
|
||||
InsertLsnNodeByHead(head_node, lsn);
|
||||
tail = InsertLsnNodeByTail(tail, lsn);
|
||||
}else{
|
||||
ReverseLsnNode(head_node);
|
||||
LWLockRelease(LogIndexMemListLock);
|
||||
return head_node;
|
||||
}
|
||||
@ -501,9 +513,8 @@ LsnNode *GetLogIndexByPage(const BufferTag *page, XLogRecPtr start_lsn, XLogRecP
|
||||
{
|
||||
if(lsn < end_lsn)
|
||||
{
|
||||
InsertLsnNodeByHead(head_node, lsn);
|
||||
tail = InsertLsnNodeByTail(tail, lsn);
|
||||
}else{
|
||||
ReverseLsnNode(head_node);
|
||||
LWLockRelease(LogIndexMemListLock);
|
||||
return head_node;
|
||||
}
|
||||
@ -514,11 +525,9 @@ LsnNode *GetLogIndexByPage(const BufferTag *page, XLogRecPtr start_lsn, XLogRecP
|
||||
}
|
||||
seg_index = item_seg->next_seg;
|
||||
}
|
||||
ReverseLsnNode(head_node);
|
||||
LWLockRelease(LogIndexMemListLock);
|
||||
return head_node;
|
||||
}
|
||||
ReverseLsnNode(head_node);
|
||||
LWLockRelease(LogIndexMemListLock);
|
||||
return head_node;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user