mirror of https://github.com/citusdata/citus.git
Columnar: use proper generic WAL interface. (#5543)
Previously, we cheated by using the RM_GENERIC_ID record type, but not actually using the generic WAL API. This worked because we always took a full page image, and saved the extra work of allocating and copying to a temporary page. But it introduced complexity, and perhaps fragility, so better to just use the API properly. The performance penalty for a serial data load seems to be less than 1%.pull/5548/head
parent
afd53e4c54
commit
1546aa0d9f
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
#include "safe_lib.h"
|
#include "safe_lib.h"
|
||||||
|
|
||||||
|
#include "access/generic_xlog.h"
|
||||||
#include "catalog/storage.h"
|
#include "catalog/storage.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "storage/bufmgr.h"
|
#include "storage/bufmgr.h"
|
||||||
|
@ -699,9 +700,12 @@ WriteToBlock(Relation rel, BlockNumber blockno, uint32 offset, char *buf,
|
||||||
uint32 len, bool clear)
|
uint32 len, bool clear)
|
||||||
{
|
{
|
||||||
Buffer buffer = ReadBuffer(rel, blockno);
|
Buffer buffer = ReadBuffer(rel, blockno);
|
||||||
|
GenericXLogState *state = GenericXLogStart(rel);
|
||||||
|
|
||||||
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
||||||
|
|
||||||
Page page = BufferGetPage(buffer);
|
Page page = GenericXLogRegisterBuffer(state, buffer, GENERIC_XLOG_FULL_IMAGE);
|
||||||
|
|
||||||
PageHeader phdr = (PageHeader) page;
|
PageHeader phdr = (PageHeader) page;
|
||||||
if (PageIsNew(page) || clear)
|
if (PageIsNew(page) || clear)
|
||||||
{
|
{
|
||||||
|
@ -734,28 +738,10 @@ WriteToBlock(Relation rel, BlockNumber blockno, uint32 offset, char *buf,
|
||||||
phdr->pd_lower = offset;
|
phdr->pd_lower = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
START_CRIT_SECTION();
|
|
||||||
|
|
||||||
memcpy_s(page + phdr->pd_lower, phdr->pd_upper - phdr->pd_lower, buf, len);
|
memcpy_s(page + phdr->pd_lower, phdr->pd_upper - phdr->pd_lower, buf, len);
|
||||||
phdr->pd_lower += len;
|
phdr->pd_lower += len;
|
||||||
|
|
||||||
MarkBufferDirty(buffer);
|
GenericXLogFinish(state);
|
||||||
|
|
||||||
if (RelationNeedsWAL(rel))
|
|
||||||
{
|
|
||||||
XLogBeginInsert();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since columnar will mostly write whole pages we force the transmission of the
|
|
||||||
* whole image in the buffer
|
|
||||||
*/
|
|
||||||
XLogRegisterBuffer(0, buffer, REGBUF_FORCE_IMAGE);
|
|
||||||
|
|
||||||
XLogRecPtr recptr = XLogInsert(RM_GENERIC_ID, 0);
|
|
||||||
PageSetLSN(page, recptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
END_CRIT_SECTION();
|
|
||||||
|
|
||||||
UnlockReleaseBuffer(buffer);
|
UnlockReleaseBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue