diff --git i/src/backend/replication/logical/reorderbuffer.c w/src/backend/replication/logical/reorderbuffer.c index cd2a0111825..9a5b5530e75 100644 --- i/src/backend/replication/logical/reorderbuffer.c +++ w/src/backend/replication/logical/reorderbuffer.c @@ -421,6 +421,9 @@ ReorderBufferReturnChange(ReorderBuffer *rb, ReorderBufferChange *change) pfree(change); } +#define TUPLEBUF_MAX_SIZE 1024 +//MaxHeapTupleSize + /* * Get a fresh ReorderBufferTupleBuf fitting at least a tuple of size * tuple_len (excluding header overhead). @@ -434,22 +437,20 @@ ReorderBufferGetTupleBuf(ReorderBuffer *rb, Size tuple_len) alloc_len = tuple_len + SizeofHeapTupleHeader; /* - * Most tuples are below MaxHeapTupleSize, so we use a slab allocator for - * those. Thus always allocate at least MaxHeapTupleSize. Note that tuples - * generated for oldtuples can be bigger, as they don't have out-of-line - * toast columns. + * Most tuples are below TUPLEBUF_MAX_SIZE, so we use a slab allocator for + * those. Thus always allocate at least TUPLEBUF_MAX_SIZE. */ - if (alloc_len < MaxHeapTupleSize) - alloc_len = MaxHeapTupleSize; + if (alloc_len < TUPLEBUF_MAX_SIZE) + alloc_len = TUPLEBUF_MAX_SIZE; /* if small enough, check the slab cache */ - if (alloc_len <= MaxHeapTupleSize && rb->nr_cached_tuplebufs) + if (alloc_len <= TUPLEBUF_MAX_SIZE && rb->nr_cached_tuplebufs) { rb->nr_cached_tuplebufs--; tuple = slist_container(ReorderBufferTupleBuf, node, slist_pop_head_node(&rb->cached_tuplebufs)); - Assert(tuple->alloc_tuple_size == MaxHeapTupleSize); + Assert(tuple->alloc_tuple_size == TUPLEBUF_MAX_SIZE); #ifdef USE_ASSERT_CHECKING memset(&tuple->tuple, 0xa9, sizeof(HeapTupleData)); VALGRIND_MAKE_MEM_UNDEFINED(&tuple->tuple, sizeof(HeapTupleData)); @@ -480,7 +481,7 @@ void ReorderBufferReturnTupleBuf(ReorderBuffer *rb, ReorderBufferTupleBuf *tuple) { /* check whether to put into the slab cache, oversized tuples never are */ - if (tuple->alloc_tuple_size == MaxHeapTupleSize && + if (tuple->alloc_tuple_size == TUPLEBUF_MAX_SIZE && rb->nr_cached_tuplebufs < max_cached_tuplebufs) { rb->nr_cached_tuplebufs++; @@ -2588,6 +2589,9 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, restored++; } + elog(DEBUG5, "restored %zu changes in XID %u into memory", + restored, txn->xid); + return restored; }