mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Fix initialization of dsa.c free area counter.
The backend local copy of dsa_area_control->freed_segment_counter was not properly initialized / maintained. This could, if unlucky, lead to keeping attached to a segment for too long. Found via valgrind bleat on buildfarm animal skink. Author: Thomas Munro Discussion: https://postgr.es/m/20170407164935.obsf2jipjfos5zei@alap3.anarazel.de
This commit is contained in:
@ -1244,6 +1244,7 @@ create_internal(void *place, size_t size,
|
|||||||
area->mapping_pinned = false;
|
area->mapping_pinned = false;
|
||||||
memset(area->segment_maps, 0, sizeof(dsa_segment_map) * DSA_MAX_SEGMENTS);
|
memset(area->segment_maps, 0, sizeof(dsa_segment_map) * DSA_MAX_SEGMENTS);
|
||||||
area->high_segment_index = 0;
|
area->high_segment_index = 0;
|
||||||
|
area->freed_segment_counter = 0;
|
||||||
LWLockInitialize(&control->lock, control->lwlock_tranche_id);
|
LWLockInitialize(&control->lock, control->lwlock_tranche_id);
|
||||||
for (i = 0; i < DSA_NUM_SIZE_CLASSES; ++i)
|
for (i = 0; i < DSA_NUM_SIZE_CLASSES; ++i)
|
||||||
LWLockInitialize(DSA_SCLASS_LOCK(area, i),
|
LWLockInitialize(DSA_SCLASS_LOCK(area, i),
|
||||||
@ -1322,6 +1323,7 @@ attach_internal(void *place, dsm_segment *segment, dsa_handle handle)
|
|||||||
errmsg("could not attach to dynamic shared area")));
|
errmsg("could not attach to dynamic shared area")));
|
||||||
}
|
}
|
||||||
++control->refcnt;
|
++control->refcnt;
|
||||||
|
area->freed_segment_counter = area->control->freed_segment_counter;
|
||||||
LWLockRelease(DSA_AREA_LOCK(area));
|
LWLockRelease(DSA_AREA_LOCK(area));
|
||||||
|
|
||||||
return area;
|
return area;
|
||||||
|
Reference in New Issue
Block a user