Fix broken logic in logical_heap_rewrite_flush_mappings().
It's blatantly obvious that commit 4d0d607a454ee832574afd52a3c515099cc85eb3 wasn't tested. The leak's real enough, though.
This commit is contained in:
parent
cee850c403
commit
c6a4ace5bf
@ -897,8 +897,7 @@ logical_heap_rewrite_flush_mappings(RewriteState state)
|
|||||||
|
|
||||||
/* write all mappings consecutively */
|
/* write all mappings consecutively */
|
||||||
len = src->num_mappings * sizeof(LogicalRewriteMappingData);
|
len = src->num_mappings * sizeof(LogicalRewriteMappingData);
|
||||||
waldata = palloc(len);
|
waldata_start = waldata = palloc(len);
|
||||||
waldata_start = waldata;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* collect data we need to write out, but don't modify ondisk data yet
|
* collect data we need to write out, but don't modify ondisk data yet
|
||||||
@ -921,6 +920,9 @@ logical_heap_rewrite_flush_mappings(RewriteState state)
|
|||||||
src->num_mappings--;
|
src->num_mappings--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert(src->num_mappings == 0);
|
||||||
|
Assert(waldata == waldata_start + len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that we deviate from the usual WAL coding practices here,
|
* Note that we deviate from the usual WAL coding practices here,
|
||||||
* check the above "Logical rewrite support" comment for reasoning.
|
* check the above "Logical rewrite support" comment for reasoning.
|
||||||
@ -933,8 +935,6 @@ logical_heap_rewrite_flush_mappings(RewriteState state)
|
|||||||
written, len)));
|
written, len)));
|
||||||
src->off += len;
|
src->off += len;
|
||||||
|
|
||||||
Assert(src->num_mappings == 0);
|
|
||||||
|
|
||||||
rdata[1].data = waldata_start;
|
rdata[1].data = waldata_start;
|
||||||
rdata[1].len = len;
|
rdata[1].len = len;
|
||||||
rdata[1].buffer = InvalidBuffer;
|
rdata[1].buffer = InvalidBuffer;
|
||||||
@ -943,6 +943,7 @@ logical_heap_rewrite_flush_mappings(RewriteState state)
|
|||||||
/* write xlog record */
|
/* write xlog record */
|
||||||
XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_REWRITE, rdata);
|
XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_REWRITE, rdata);
|
||||||
|
|
||||||
|
pfree(waldata_start);
|
||||||
}
|
}
|
||||||
Assert(state->rs_num_rewrite_mappings == 0);
|
Assert(state->rs_num_rewrite_mappings == 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user