ApsaraDB / PolarDB-for-PostgreSQL

A cloud-native database based on PostgreSQL developed by Alibaba Cloud.
https://apsaradb.github.io/PolarDB-for-PostgreSQL/zh/
Apache License 2.0
2.89k stars 480 forks source link

Fail to run PolarDB[Question] #271

Closed Weijun-H closed 2 years ago

Weijun-H commented 2 years ago

Describe the problem

... When I tried to rerun ./polardb_build.sh --initpx in docker polardb/polardb_pg_devel , I met this error.

2022-07-06 11:31:09.833 UTC [88204] WARNING:  polardb skip readControlfile
2022-07-06 11:31:09.833 UTC [88204] LOG:  polar_replica = 'on'
2022-07-06 11:31:09.833 UTC [88204] LOG:  read polar_replica = on, polardb in replica mode, use ro mode mount pfs
2022-07-06 11:31:09.834 UTC [88204] LOG:  polar_vfs loaded in postmaster 88204
2022-07-06 11:31:09.836 UTC [88204] WARNING:  could not access file "polar_resource_group": No such file or directory
2022-07-06 11:31:09.838 UTC [88204] LOG:  Auto detecting polar_stat_sql.linux_hz parameter...
2022-07-06 11:31:09.838 UTC [88204] LOG:  polar_stat_sql.linux_hz is set to 1000000
2022-07-06 11:31:09.843 UTC [88204] LOG:  listening on IPv4 address "0.0.0.0", port 5433
2022-07-06 11:31:09.843 UTC [88204] LOG:  listening on IPv6 address "::", port 5433
2022-07-06 11:31:09.844 UTC [88204] LOG:  listening on Unix socket "./.s.PGSQL.5433"
2022-07-06 11:31:09.845 UTC [88204] LOG:  clog buffer max slot size is 256, and it will be set to 256
2022-07-06 11:31:09.845 UTC [88204] LOG:  commit timestamp buffer max slot size is 128, and it will set to 16
2022-07-06 11:31:09.845 UTC [88204] LOG:  The total log index memory table size is 402525528
2022-07-06 11:31:09.845 UTC [88204] LOG:  The total log index memory table size is 133987128
2022-07-06 11:31:09.845 UTC [88204] LOG:  The total log index memory table size is 66993864
2022-07-06 11:31:09.847 UTC [88204] FATAL:  could not map anonymous shared memory: Cannot allocate memory
2022-07-06 11:31:09.847 UTC [88204] HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 2644295680 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
2022-07-06 11:31:09.847 UTC [88204] BACKTRACE:  
        /home/postgres/tmp_basedir_polardb_pg_1100_bld/bin/postgres(PGSharedMemoryCreate+0x726) [0xa12fe6]
        /home/postgres/tmp_basedir_polardb_pg_1100_bld/bin/postgres(CreateSharedMemoryAndSemaphores+0x3c0) [0xa95a80]
        /home/postgres/tmp_basedir_polardb_pg_1100_bld/bin/postgres(PostmasterMain+0xa6d) [0xa2b36d]
        /home/postgres/tmp_basedir_polardb_pg_1100_bld/bin/postgres(main+0x781) [0x72a0b1]
        /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f54218e2555]
        /home/postgres/tmp_basedir_polardb_pg_1100_bld/bin/postgres() [0x735f8c]
2022-07-06 11:31:09.847 UTC [88204] LOG:  database system is shut down
 stopped waiting
pg_ctl: could not start server
Examine the log output.

I did not do anything except running that command.

polardb-bot[bot] commented 2 years ago

Hi @Weijun-H ~ Thanks for opening this issue! 🎉

Please make sure you have provided enough information for subsequent discussion.

We will get back to you as soon as possible. ❤️

mrdrivingduck commented 2 years ago

Hi @Weijun-H ~

Is your container provided with enough memory? Could you please provide more information about your machine, like hardware, OS version, Docker version? If you are using Docker Desktop on macOS, I suggest you to increase the memory limit to 4GB or higher.

Weijun-H commented 2 years ago

Hi @mrdrivingduck Here is Docker and Ubuntu version

Docker version 20.10.17, build 100c701
Linux version 5.4.0-110-generic (buildd@ubuntu) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #124-Ubuntu SMP Thu Apr 14 19:46:19 UTC 2022

Here is memory info

MemTotal:       16005396 kB
MemFree:         1673280 kB
MemAvailable:   11015920 kB
Buffers:          138092 kB
Cached:         10652724 kB
SwapCached:            0 kB
Active:          6172912 kB
Inactive:        7292776 kB
Active(anon):    2724788 kB
Inactive(anon):  1586192 kB
Active(file):    3448124 kB
Inactive(file):  5706584 kB
Unevictable:       18464 kB
Mlocked:           18464 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2693488 kB
Mapped:          1411960 kB
Shmem:           1631448 kB
KReclaimable:     528596 kB
Slab:             712872 kB
SReclaimable:     528596 kB
SUnreclaim:       184276 kB
KernelStack:       19616 kB
PageTables:        43984 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    15205124 kB
Committed_AS:   13997112 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       30176 kB
VmallocChunk:          0 kB
Percpu:             7424 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      325488 kB
DirectMap2M:    12912640 kB
DirectMap1G:     3145728 kB
mrdrivingduck commented 2 years ago

@Weijun-H

By going through the backtrace, I notice that PostgreSQL cannot allocate more shared memory. So possible solutions include:

Weijun-H commented 2 years ago

@mrdrivingduck I have solved this problem by reconfiguring the OS settings. This problem is caused by the Greenplum installation.