146#if defined(__darwin__) && SIZEOF_VOID_P == 8
209 elog(
LOG,
"shmctl(%d, %d, 0) failed: %m",
225 (
errmsg(
"could not create shared memory segment: %m"),
226 errdetail(
"Failed system call was shmget(key=%lu, size=%zu, 0%o).",
227 (
unsigned long)
memKey, size,
230 errhint(
"This error usually means that PostgreSQL's request for a shared memory "
231 "segment exceeded your kernel's SHMMAX parameter, or possibly that "
233 "your kernel's SHMMIN parameter.\n"
234 "The PostgreSQL documentation contains more information about shared "
235 "memory configuration.") : 0,
237 errhint(
"This error usually means that PostgreSQL's request for a shared "
238 "memory segment exceeded your kernel's SHMALL parameter. You might need "
239 "to reconfigure the kernel with larger SHMALL.\n"
240 "The PostgreSQL documentation contains more information about shared "
241 "memory configuration.") : 0,
243 errhint(
"This error does *not* mean that you have run out of disk space. "
244 "It occurs either if all available shared memory IDs have been taken, "
245 "in which case you need to raise the SHMMNI parameter in your kernel, "
246 "or because the system's overall limit for shared memory has been "
248 "The PostgreSQL documentation contains more information about shared "
249 "memory configuration.") : 0));
259 elog(
FATAL,
"shmat(id=%d, addr=%p, flags=0x%x) failed: %m",
302 elog(
LOG,
"shmctl(%d, %d, 0) failed: %m",
386#ifdef HAVE_LINUX_EIDRM_BUG
429#ifdef HAVE_LINUX_EIDRM_BUG
439 hdr->device !=
statbuf.st_dev ||
550#if defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT)
581#if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
602 Size allocsize = *size;
628 elog(
DEBUG1,
"mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m",
657 (
errmsg(
"could not map anonymous shared memory: %m"),
659 errhint(
"This error usually means that PostgreSQL's request "
660 "for a shared memory segment exceeded available memory, "
661 "swap space, or huge pages. To reduce the request size "
662 "(currently %zu bytes), reduce PostgreSQL's shared "
663 "memory usage, perhaps by reducing \"shared_buffers\" or "
664 "\"max_connections\".",
683 elog(
LOG,
"munmap(%p, %zu) failed: %m",
719 errmsg(
"could not stat data directory \"%s\": %m",
723#if !defined(MAP_HUGETLB)
727 errmsg(
"huge pages not supported on this platform")));
734 errmsg(
"huge pages not supported with the current \"shared_memory_type\" setting")));
800 errmsg(
"pre-existing shared memory block (key %lu, ID %lu) is still in use",
802 (
unsigned long)
shmid),
803 errhint(
"Terminate any old server processes associated with data directory \"%s\".",
814 "shared memory block (key %lu, ID %lu) deleted during startup",
816 (
unsigned long)
shmid);
833 if (
oldhdr->dsm_control != 0)
915 elog(
FATAL,
"could not reattach to shared memory (key=%d, addr=%p): %m",
918 elog(
FATAL,
"reattaching to shared memory returned unexpected address (got %p, expected %p)",
989 elog(
LOG,
"munmap(%p, %zu) failed: %m",
#define Assert(condition)
void dsm_cleanup_using_control_segment(dsm_handle old_control_handle)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
FILE * AllocateFile(const char *name, const char *mode)
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
#define GUC_check_errdetail
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
void AddToDataDirLockFile(int target_line, const char *str)
static uint64 pg_ceil_log2_64(uint64 num)
static rewind_source * source
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define LOCK_FILE_LINE_SHMEM_KEY
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
Size add_size(Size s1, Size s2)
static void AnonymousShmemDetach(int status, Datum arg)
void PGSharedMemoryDetach(void)
@ SHMSTATE_ANALYSIS_FAILURE
PGShmemHeader * PGSharedMemoryCreate(Size size, PGShmemHeader **shim)
static Size AnonymousShmemSize
unsigned long UsedShmemSegID
bool check_huge_page_size(int *newval, void **extra, GucSource source)
static void * CreateAnonymousSegment(Size *size)
static void * InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
void GetHugePageSize(Size *hugepagesize, int *mmap_flags)
bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
static void IpcMemoryDetach(int status, Datum shmaddr)
static IpcMemoryState PGSharedMemoryAttach(IpcMemoryId shmId, void *attachAt, PGShmemHeader **addr)
static void * AnonymousShmem
static void IpcMemoryDelete(int status, Datum shmId)
void PGSharedMemoryReAttach(void)
void PGSharedMemoryNoReAttach(void)