secondbuffer process maybe clean latest version page

Signed-off-by: shipixian <shipixian_yewu@cmss.chinamobile.com>
This commit is contained in:
shipixian 2023-06-29 10:37:06 +08:00
parent 5fc75be472
commit 09e0548903
3 changed files with 27 additions and 8 deletions

View File

@ -324,17 +324,17 @@ static bool
CleanUpSecondBuffer(const SdPageKey *pk)
{
LWLock *partitionLock;
uint32 newHash;
newHash = SecondBufferHashCode(pk);
partitionLock = SecondBufferMappingPartitionLock(newHash);
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
// LWLock *partitionLock;
// uint32 newHash;
// newHash = SecondBufferHashCode(pk);
// partitionLock = SecondBufferMappingPartitionLock(newHash);
// LWLockAcquire(partitionLock, LW_EXCLUSIVE);
bool found;
hash_search(SecondBufferHash,
(void *)pk,
HASH_REMOVE,
&found);
LWLockRelease(partitionLock);
// LWLockRelease(partitionLock);
return found;
}
@ -381,6 +381,7 @@ ReceivePageFromDataBuffer(PageKey *pk, uint8_t *buffer)
LWLockRelease(partitionLock);
continue;
}
sdPageValue->canDelete = false;
memcpy(sdPageValue->pagecontent, buffer,8192);
LWLockRelease(partitionLock);
}
@ -1054,7 +1055,12 @@ RemovePageOrWalFromCurrentNode()
mdb_cursor_del(tmpcursor,0);
if (PageOrWal == (int)PAGE)
{
// CleanUpSecondBuffer(&((SdPageValue *)data.mv_data)->pk);
newHash = SecondBufferHashCode(&((SdPageValue *)data.mv_data)->pk);
partitionLock = SecondBufferMappingPartitionLock(newHash);
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
CleanUpSecondBuffer(&((SdPageValue *)data.mv_data)->pk);
LWLockRelease(partitionLock);
}
}
@ -1063,7 +1069,12 @@ RemovePageOrWalFromCurrentNode()
//TRUNCATE
if (DPArray->dpk[DPArray->walIndex].operation == (int)TRUNCATE)
{
// CleanUpSecondBuffer(&((SdPageValue *)data.mv_data)->pk);
newHash = SecondBufferHashCode(&((SdPageValue *)data.mv_data)->pk);
partitionLock = SecondBufferMappingPartitionLock(newHash);
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
CleanUpSecondBuffer(&((SdPageValue *)data.mv_data)->pk);
LWLockRelease(partitionLock);
}
else if (NULL == FindSecondBufferInTable(&lpk->sk)) //EVICT
{
@ -1229,6 +1240,7 @@ MovePageFromSecondBufferToLocalBuffer()
data.mv_data = spv->pagecontent;
mp = mdb_put(tmptxn,pageDbi,&key,&data, 0);
spv->canDelete = true;
LWLockRelease(partitionLock);
if (mp != 0)
{
@ -1264,7 +1276,12 @@ MovePageFromSecondBufferToLocalBuffer()
spv = FindSecondBufferInTable(&s->spk);
if (spv != NULL)
{
CleanUpSecondBuffer(&s->spk);
newHash = SecondBufferHashCode(&s->spk);
partitionLock = SecondBufferMappingPartitionLock(newHash);
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
if (spv->canDelete)
CleanUpSecondBuffer(&s->spk);
LWLockRelease(partitionLock);
}
}
if (spkl.head->next != NULL)

View File

@ -354,6 +354,7 @@ extern void UpdateControlFile(void);
extern void PushUpdateControlFile(void);
extern void PushCheckPointGuts(XLogRecPtr checkPointRedo, int flags);
extern XLogRecPtr GetXLogPushToDisk(void);
extern void SetXLogPushToDisk(XLogRecPtr pushToDiskLsn);
extern uint64 GetSystemIdentifier(void);
extern char *GetMockAuthenticationNonce(void);

View File

@ -70,7 +70,8 @@ typedef struct OriginDPageKey
typedef struct SdPageValue
{
SdPageKey pk;
SdPageKey pk;
bool canDelete;
uint8 pagecontent[BLKSZ];
} SdPageValue;