Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix small query-lifespan memory leak in bulk updates.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Aug 2016 02:20:01 +0000 (22:20 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Aug 2016 02:20:01 +0000 (22:20 -0400)
When there is an identifiable REPLICA IDENTITY index on the target table,
heap_update leaks the id_attrs bitmapset.  That's not many bytes, but it
adds up over enough rows, since the code typically runs in a query-lifespan
context.  Bug introduced in commit e55704d8b, which did a rather poor job
of cloning the existing use-pattern for RelationGetIndexAttrBitmap().

Per bug #14293 from Zhou Digoal.  Back-patch to 9.4 where the bug was
introduced.

Report: <20160824114320.15676.45171@wrigleys.postgresql.org>

src/backend/access/heap/heapam.c

index ee2dd57ec642d1a27370c56ac7aa639a80cabd3d..b8f4fe570acf6b27ef3a2a2f4ed0ae34ea2e505e 100644 (file)
@@ -3579,6 +3579,7 @@ l2:
            ReleaseBuffer(vmbuffer);
        bms_free(hot_attrs);
        bms_free(key_attrs);
+       bms_free(id_attrs);
        return result;
    }
 
@@ -4031,6 +4032,7 @@ l2:
 
    bms_free(hot_attrs);
    bms_free(key_attrs);
+   bms_free(id_attrs);
 
    return HeapTupleMayBeUpdated;
 }