Closed JerrySievert closed 9 months ago
I was not able to find a way to create a test to verify the results, verification was done by adding a memory walking debug output (which I removed) that showed the existence of thousands of memory contexts (all 8k) that went away after my fix.
during logical replication of large tables, multiple
MemoryContext
's are created viaCreateColumnarScanMemoryContext()
and do not get removed, eventually resulting in theOOM
killer killing off the replication process and forcibly restarting the database.since a scan context can get used outside of an actual read, it did not make sense to delete it in
ColumnarEndRead()
, so individual scan contexts are deleted when the function that created them are about to end execution.this eliminates the ever-growing of scan contexts that appear under
TopMemoryContext
, and fixes the leak.