/* Obtain a span object. */
span_pointer = alloc_object(area, DSA_SCLASS_BLOCK_OF_SPANS);
if (!DsaPointerIsValid(span_pointer))
+ {
+ /* Raise error unless asked not to. */
+ if ((flags & DSA_ALLOC_NO_OOM) == 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory"),
+ errdetail("Failed on DSA request of size %zu.",
+ size)));
return InvalidDsaPointer;
+ }
LWLockAcquire(DSA_AREA_LOCK(area), LW_EXCLUSIVE);
{
/* Raise error unless asked not to. */
if ((flags & DSA_ALLOC_NO_OOM) == 0)
- {
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
errdetail("Failed on DSA request of size %zu.", size)));
- }
return InvalidDsaPointer;
}
return false;
}
}
+ /*
+ * This shouldn't happen: get_best_segment() or make_new_segment()
+ * promised that we can successfully allocate npages.
+ */
if (!FreePageManagerGet(segment_map->fpm, npages, &first_page))
- {
- LWLockRelease(DSA_AREA_LOCK(area));
- if (size_class != DSA_SCLASS_BLOCK_OF_SPANS)
- dsa_free(area, span_pointer);
- return false;
- }
+ elog(FATAL,
+ "dsa_allocate could not find %zu free pages for superblock",
+ npages);
LWLockRelease(DSA_AREA_LOCK(area));
/* Compute the start of the superblock. */