powered by simpleCommunicator - 2.0.18     © 2024 Programmizd 02
Map
Форумы / PostgreSQL [игнор отключен] [закрыт для гостей] / Cannot allocate memory
12 сообщений из 12, страница 1 из 1
Cannot allocate memory
    #40133273
dmitry7
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Добрый день.

Друзья, подскажите по механикам выделения памяти Постргесом. PG 12.3. Параметры виртуалки 4CPU, 8GB RAM. Много подключений, выполняющих короткие запросы, или в статусе Idle. Постоянно валятся ошибки Cannot allocate memory, Out of memory.
Что ему надо?

Конфиг Postgres
max_connections = 515
shared_buffers = 2048MB
huge_pages = try
work_mem = 32MB
dynamic_shared_memory_type = posix

$ free -m
total used free shared buff/cache available
Mem: 7821 1862 3649 241 2309 5638
Swap: 8191 0 8191

Лог

LOG: could not fork autovacuum worker process: Cannot allocate memory
HOST: DB: USER: LOG: could not fork new process for connection: Cannot allocate memory
PID:7567 HOST:192.168.0.12 DB:postgres USER:postgres FATAL: out of memory
LOG: could not fork autovacuum worker process: Cannot allocate memory
TopMemoryContext: 305968 total in 11 blocks; 42424 free (15 chunks); 263544 used
smgr relation table: 16384 total in 2 blocks; 4600 free (2 chunks); 11784 used
pgstat TabStatusArray lookup hash table: 8192 total in 1 blocks; 1456 free (0 chunks); 6736 used
TopTransactionContext: 8192 total in 1 blocks; 6656 free (10 chunks); 1536 used
TransactionAbortContext: 32768 total in 1 blocks; 32512 free (0 chunks); 256 used
Portal hash: 8192 total in 1 blocks; 560 free (0 chunks); 7632 used
TopPortalContext: 8192 total in 1 blocks; 7936 free (0 chunks); 256 used
Relcache by OID: 16384 total in 2 blocks; 7672 free (2 chunks); 8712 used
CacheMemoryContext: 262144 total in 6 blocks; 280 free (3 chunks); 261864 used
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_foreign_table_relid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_type_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_aggregate_fnoid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_constraint_oid_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_rewrite_rel_rulename_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_ts_parser_prsname_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_ts_config_cfgname_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_ts_parser_oid_index
index info: 2048 total in 2 blocks; 728 free (1 chunks); 1320 used: pg_publication_rel_prrelid_prpubid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_operator_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_namespace_nspname_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_ts_template_oid_index
index info: 2048 total in 2 blocks; 704 free (3 chunks); 1344 used: pg_amop_opr_fam_index
index info: 2048 total in 2 blocks; 672 free (3 chunks); 1376 used: pg_default_acl_role_nsp_obj_index
index info: 2048 total in 2 blocks; 704 free (3 chunks); 1344 used: pg_collation_name_enc_nsp_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_publication_rel_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_range_rngtypid_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_ts_dict_dictname_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_type_typname_nsp_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_opfamily_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_statistic_ext_oid_index
index info: 1024 total in 1 blocks; 16 free (0 chunks); 1008 used: pg_statistic_ext_data_stxoid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_class_oid_index
index info: 2048 total in 2 blocks; 704 free (3 chunks); 1344 used: pg_proc_proname_args_nsp_index
index info: 1024 total in 1 blocks; 16 free (0 chunks); 1008 used: pg_partitioned_table_partrelid_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_transform_type_lang_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_attribute_relid_attnum_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_proc_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_language_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_namespace_oid_index
index info: 3072 total in 2 blocks; 1216 free (3 chunks); 1856 used: pg_amproc_fam_proc_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_foreign_server_name_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_attribute_relid_attnam_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_conversion_oid_index
index info: 2048 total in 2 blocks; 728 free (1 chunks); 1320 used: pg_user_mapping_user_server_index
index info: 2048 total in 2 blocks; 728 free (1 chunks); 1320 used: pg_subscription_rel_srrelid_srsubid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_sequence_seqrelid_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_conversion_name_nsp_index
index info: 2048 total in 2 blocks; 952 free (1 chunks); 1096 used: pg_authid_oid_index
index info: 2048 total in 2 blocks; 648 free (1 chunks); 1400 used: pg_auth_members_member_role_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_subscription_oid_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_tablespace_oid_index
index info: 2048 total in 2 blocks; 704 free (3 chunks); 1344 used: pg_shseclabel_object_index
index info: 1024 total in 1 blocks; 16 free (0 chunks); 1008 used: pg_replication_origin_roname_index
index info: 2048 total in 2 blocks; 952 free (1 chunks); 1096 used: pg_database_datname_index
index info: 2048 total in 2 blocks; 760 free (2 chunks); 1288 used: pg_subscription_subname_index
index info: 1024 total in 1 blocks; 16 free (0 chunks); 1008 used: pg_replication_origin_roiident_index
index info: 2048 total in 2 blocks; 728 free (1 chunks); 1320 used: pg_auth_members_role_member_index
index info: 1024 total in 1 blocks; 48 free (0 chunks); 976 used: pg_database_oid_index
index info: 2048 total in 2 blocks; 952 free (1 chunks); 1096 used: pg_authid_rolname_index
WAL record construction: 49768 total in 2 blocks; 6368 free (0 chunks); 43400 used
PrivateRefCount: 8192 total in 1 blocks; 2624 free (0 chunks); 5568 used
MdSmgr: 8192 total in 1 blocks; 7936 free (0 chunks); 256 used
LOCALLOCK hash: 8192 total in 1 blocks; 560 free (0 chunks); 7632 used
Timezones: 104120 total in 2 blocks; 2624 free (0 chunks); 101496 used
Postmaster: 16384 total in 2 blocks; 15240 free (12 chunks); 1144 used
ident parser context: 1024 total in 1 blocks; 768 free (0 chunks); 256 used
hba parser context: 17408 total in 5 blocks; 3720 free (5 chunks); 13688 used
ErrorContext: 8192 total in 1 blocks; 7936 free (5 chunks); 256 used
Grand total: 964688 bytes in 116 blocks; 171712 free (100 chunks); 792976 used
PID:7573 HOST:192.168.0.12 DB:postgres USER:postgres FATAL: out of memory
PID:7573 HOST:192.168.0.12 DB:postgres USER:postgres DETAIL: Failed on request of size 140 in memory context "CacheMemoryContext".
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133504
pg000
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Код: plsql
1.
grep -i "kill" /var/log/messages 2>/dev/null || grep -i "kill" /var/log/syslog 2>/dev/null


?
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133506
dmitry7
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
pg000, пусто
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133521
Guzya
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Код: sql
1.
 select state,count(*) from pg_stat_activity group by state;
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133524
dmitry7
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Guzya,

Код: plsql
1.
select state,count(*) from pg_stat_activity group by state;


Код: plsql
1.
2.
active | 1
idle | 328
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133530
Guzya
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
dmitry7, возможно Вам стоит посмотреть в сторону пулов соединений (pgbouncer например).
Что еще стоит на сервере подъедающее память?
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133535
dmitry7
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Guzya, на сервере кроме СУБД больше ничего не установлено. ОС Ubuntu. В сторону пула для соединений движемся, но пока использовать его возможности нет. Я знаю, что PG плохо работает с большим количеством соединений.
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133536
Guzya
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Гугление показало, что надо посмотреть

Код: sql
1.
2.
-- из под пользователя postgres
ulimit -a



Код: sql
1.
2.
3.
cat /proc/meminfo 

cat /proc/sys/vm/overcommit_memory
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40133539
Фотография Maxim Boguk
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
dmitry7
Guzya, на сервере кроме СУБД больше ничего не установлено. ОС Ubuntu. В сторону пула для соединений движемся, но пока использовать его возможности нет. Я знаю, что PG плохо работает с большим количеством соединений.


умножаем
max_connections = 515 * work_mem = 32MB
получаем 16480MB = 16GB

памяти имеем 8GB (а реально 6GB так как shared_buffers)
а чего вы хотите то тогда?

или work_mem 4MB ставьте или лимит на коннекты 100

или прекратите использовать в качестве сервера виртуалки в 4ре раза слабее по памяти чем мой ноут рабочий.

--
Maxim Boguk
лучшая поддержка PostgreSQL: dataegret.ru
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40134442
dmitry7
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Maxim Boguk,

Про СУБД на калькуляторе понятно. И тем не менее, почему он swap не использует? Вот пример с другого сервера.
267 cсесиий Idle.
Код: sql
1.
2.
3.
4.
[postgres]$ free -m
              total        used        free      shared  buff/cache   available
Mem:          15885        3602         129        3193       12152        8959
Swap:          4095         113        3982



Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
[postgres]$ cat /proc/meminfo
MemTotal:       16266524 kB
MemFree:          109820 kB
MemAvailable:    9183616 kB
Buffers:               0 kB
Cached:          8559196 kB
SwapCached:          144 kB
Active:          8636400 kB
Inactive:        2939592 kB
Active(anon):    5156836 kB
Inactive(anon):  1129792 kB
Active(file):    3479564 kB
Inactive(file):  1809800 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       4194300 kB
SwapFree:        4078068 kB
Dirty:              1072 kB
Writeback:             0 kB
AnonPages:       3016660 kB
Mapped:          2813776 kB
Shmem:           3269828 kB
Slab:            4020300 kB
SReclaimable:    3916940 kB
SUnreclaim:       103360 kB
KernelStack:       14512 kB
PageTables:       356936 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    12327560 kB
Committed_AS:   12290188 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      172952 kB
VmallocChunk:   34359341052 kB
Percpu:              752 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40134443
Guzya
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Если я правильно понимаю, то выставлен лимит в ~11Гб (CommitLimit: 12327560 kB)

Ознакомьтесь fork: Cannot allocate memory
...
Рейтинг: 0 / 0
Cannot allocate memory
    #40134477
dmitry7
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Guzya,
спасибо, это оно.
...
Рейтинг: 0 / 0
12 сообщений из 12, страница 1 из 1
Форумы / PostgreSQL [игнор отключен] [закрыт для гостей] / Cannot allocate memory
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали тему (1): Анонимы (1)
Читали форум (1): Анонимы (1)
Пользователи онлайн (8): Анонимы (6), Bing Bot 1 мин., Yandex Bot 2 мин.
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]