fix bug when copy wal into walbuffer

Signed-off-by: shipixian <shipixian_yewu@cmss.chinamobile.com>
This commit is contained in:
shipixian 2023-03-28 13:59:24 +08:00
parent 2311fe482a
commit 7e8e77b95f

View File

@ -2140,9 +2140,9 @@ He3DBCopyXLogRecordToWAL(int write_len, XLogRecPtr StartPos, XLogRecPtr EndPos)
*
* xlog的长度超过剩余空间xlog buffer的起始地址开始复制
*/
// int XlogBufferLength = (XLOGbuffers-1) * XLOG_BLCKSZ;
// int UsedXlogBufferLength = StartPos % ((XLOGbuffers-1) * XLOG_BLCKSZ);
// int remaindXlogBufferLength = XlogBufferLength - UsedXlogBufferLength;
int XlogBufferLength = (XLOGbuffers-1) * XLOG_BLCKSZ;
int UsedXlogBufferLength = StartPos % ((XLOGbuffers-1) * XLOG_BLCKSZ);
int remaindXlogBufferLength = XlogBufferLength - UsedXlogBufferLength;
/*
* Get a pointer to the right place in the right WAL buffer to start
* inserting to.
@ -2159,6 +2159,8 @@ He3DBCopyXLogRecordToWAL(int write_len, XLogRecPtr StartPos, XLogRecPtr EndPos)
for (int i = 0; i < grouo_rec_count; i++)
{
rdata = (XLogRecData *)&groupRecData[i];
if (remaindXlogBufferLength <= 0)
currpos = XLogCtl->pages - remaindXlogBufferLength;
while (rdata != NULL)
{
char *rdata_data = rdata->data;
@ -2180,6 +2182,7 @@ He3DBCopyXLogRecordToWAL(int write_len, XLogRecPtr StartPos, XLogRecPtr EndPos)
CurrPos += rdata_len;
written += rdata_len;
remaindXlogBufferLength -= rdata_len;
rdata = rdata->next;
}
}