arkhipov / temporal_tables

Temporal Tables PostgreSQL Extension
BSD 2-Clause "Simplified" License
927 stars 46 forks source link

Memory "leak" on every update #24

Closed tserr closed 7 years ago

tserr commented 7 years ago

We observed, that every update on a row of a temporal enables tables leads to ~15KB additional memory usage of the processes for a connection.

Our researches showed that this memory usage is caused by lookup_versioning_hash_entry because already created entries are not found.

Steps we did to analyse:

We don't really understand

But ensuring "entry->relid" is set after the "memset" solves the issue for us.

diff --git a/versioning.c b/versioning.c
index 2497c2f..0599530 100644
--- a/versioning.c
+++ b/versioning.c
@@ -1080,6 +1080,7 @@ lookup_versioning_hash_entry(Oid relid,
        if (!*found)
        {
                memset(entry, 0, sizeof(VersioningHashEntry));
+               entry->relid = relid;

                /* Mark a newly created entry invalid. */
                entry->natts = -1;
arkhipov commented 7 years ago

Could you please check if the current version works for you?

tserr commented 7 years ago

Thanks for the fast support. The current version fixes this issue for us.