manticoresoftware / manticoresearch

Easy to use open source fast database for search | Good alternative to Elasticsearch now | Drop-in replacement for E in the ELK soon
https://manticoresearch.com
GNU General Public License v3.0
8.94k stars 496 forks source link

Manticore Out of Memory Regardless of 500GB Available Memory #2392

Open JubilantJerry opened 2 months ago

JubilantJerry commented 2 months ago

Bug Description:

Manticore crashes during indexing with a Fatal: out of memory error, even though Manticore is only using 35GB and the system has more than 500GB free out of 770GB total. Even the Virtual Memory column shown on top (which should be irrelevant) is only 280GB. The system does not actually have any memory pressure. Manticore reports the error on startup trying to allocate only 5.6MB when replaying binlogs, and enters a loop of repeated restarts. I've since disabled the offending index from manticore.json, let Manticore start up (which made it delete binlog files), then added the table back into manticore.json.

Logs:

[Tue Jul  9 12:29:37.777 2024] [1897613] listening on 127.0.0.1:9312 for sphinx and http(s)
[Tue Jul  9 12:29:37.777 2024] [1897613] listening on 127.0.0.1:9306 for mysql
[Tue Jul  9 12:29:37.777 2024] [1897613] listening on 127.0.0.1:9308 for sphinx and http(s)
[Tue Jul  9 12:29:37.780 2024] [1897613] DEBUG: Frame expression stack for creation is 16 (mocked, as no env MANTICORE_KNOWN_CREATE_SIZE=16 found)
[Tue Jul  9 12:29:37.780 2024] [1897613] DEBUG: Starting expression stack for creation is 3008 (mocked, as no env MANTICORE_START_KNOWN_CREATE_SIZE=3008 found)
[Tue Jul  9 12:29:37.781 2024] [1897613] DEBUG: Frame expression stack for eval/deletion is 32 (mocked, as no env MANTICORE_KNOWN_EXPR_SIZE=32 found)
[Tue Jul  9 12:29:37.781 2024] [1897613] DEBUG: Starting expression stack for eval/deletion is 104 (mocked, as no env MANTICORE_START_KNOWN_EXPR_SIZE=104 found)
[Tue Jul  9 12:29:37.785 2024] [1897613] DEBUG: Frame filter stack delta is 224 (mocked, as no env MANTICORE_KNOWN_FILTER_SIZE=224 found)
[Tue Jul  9 12:29:37.785 2024] [1897613] DEBUG: Starting filter stack delta is 11184 (mocked, as no env MANTICORE_START_KNOWN_FILTER_SIZE=11184 found)
[Tue Jul  9 12:29:37.793 2024] [1897613] DEBUG: Frame fulltext match stack delta is 320 (mocked, as no env MANTICORE_KNOWN_MATCH_SIZE=320 found)
[Tue Jul  9 12:29:37.793 2024] [1897613] DEBUG: Starting fulltext match stack delta is 14536 (mocked, as no env MANTICORE_START_KNOWN_MATCH_SIZE=14536 found)
[Tue Jul  9 12:29:37.793 2024] [1897613] DEBUG: 'rt_flush_period' - nothing specified, using default value 36000000000
[Tue Jul  9 12:29:37.793 2024] [1897615] DEBUG: 'embedded_limit' - nothing specified, using default value 16384
[Tue Jul  9 12:29:37.793 2024] [1897615] DEBUG: 'attr_update_reserve' - nothing specified, using default value 131072
[Tue Jul  9 12:29:37.793 2024] [1897615] DEBUG: 'docstore_block_size' - nothing specified, using default value 16384
[Tue Jul  9 12:29:58.795 2024] [1897615] DEBUG: 'embedded_limit' - nothing specified, using default value 16384
[Tue Jul  9 12:29:58.795 2024] [1897615] DEBUG: 'attr_update_reserve' - nothing specified, using default value 131072
[Tue Jul  9 12:29:58.795 2024] [1897615] DEBUG: 'docstore_block_size' - nothing specified, using default value 16384
[Tue Jul  9 12:30:01.462 2024] [1897613] DEBUG: 'binlog_max_log_size' - nothing specified, using default value 268435456
[Tue Jul  9 12:30:01.462 2024] [1897613] DEBUG: MAC address b0:3a:f2:b6:05:9f for uuid-short server_id
[Tue Jul  9 12:30:01.462 2024] [1897613] DEBUG: uid-short server_id 108, started 163830601, seed 7784968777476603904
[Tue Jul  9 12:30:01.463 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.011
[Tue Jul  9 12:30:02.146 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1229453
[Tue Jul  9 12:30:02.146 2024] [1897622] binlog: replay stats: 133 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:02.146 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.011; 256.3 MB in 0.682 sec
[Tue Jul  9 12:30:02.146 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.012
[Tue Jul  9 12:30:02.837 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1229585
[Tue Jul  9 12:30:02.837 2024] [1897622] binlog: replay stats: 132 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:02.837 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.012; 256.2 MB in 0.690 sec
[Tue Jul  9 12:30:02.837 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.013
[Tue Jul  9 12:30:03.482 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1229718
[Tue Jul  9 12:30:03.482 2024] [1897622] binlog: replay stats: 133 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:03.482 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.013; 256.2 MB in 0.644 sec
[Tue Jul  9 12:30:03.482 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.014
[Tue Jul  9 12:30:04.128 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1229852
[Tue Jul  9 12:30:04.128 2024] [1897622] binlog: replay stats: 134 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:04.128 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.014; 256.9 MB in 0.646 sec
[Tue Jul  9 12:30:04.128 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.015
[Tue Jul  9 12:30:04.818 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1229983
[Tue Jul  9 12:30:04.818 2024] [1897622] binlog: replay stats: 131 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:04.818 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.015; 256.2 MB in 0.689 sec
[Tue Jul  9 12:30:04.818 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.016
[Tue Jul  9 12:30:05.469 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1230000
[Tue Jul  9 12:30:05.469 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153531
[Tue Jul  9 12:30:05.469 2024] [1897622] binlog: replay stats: 48 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 2 tables
[Tue Jul  9 12:30:05.469 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.016; 258.6 MB in 0.650 sec
[Tue Jul  9 12:30:05.469 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.017
[Tue Jul  9 12:30:06.112 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153566
[Tue Jul  9 12:30:06.112 2024] [1897622] binlog: replay stats: 35 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:06.112 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.017; 257.4 MB in 0.643 sec
[Tue Jul  9 12:30:06.112 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.018
[Tue Jul  9 12:30:06.753 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153601
[Tue Jul  9 12:30:06.753 2024] [1897622] binlog: replay stats: 35 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:06.753 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.018; 256.7 MB in 0.640 sec
[Tue Jul  9 12:30:06.753 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.019
[Tue Jul  9 12:30:07.440 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153636
[Tue Jul  9 12:30:07.440 2024] [1897622] binlog: replay stats: 35 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:07.440 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.019; 257.1 MB in 0.686 sec
[Tue Jul  9 12:30:07.440 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.020
[Tue Jul  9 12:30:08.090 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153671
[Tue Jul  9 12:30:08.090 2024] [1897622] binlog: replay stats: 35 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:08.090 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.020; 259.0 MB in 0.650 sec
[Tue Jul  9 12:30:08.090 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.021
[Tue Jul  9 12:30:08.748 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153707
[Tue Jul  9 12:30:08.748 2024] [1897622] binlog: replay stats: 36 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:08.748 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.021; 262.7 MB in 0.658 sec
[Tue Jul  9 12:30:08.748 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.022
[Tue Jul  9 12:30:09.451 2024] [1897622] binlog: table pile_super_all: skipped at tid 153746 and max binlog tid 153743
[Tue Jul  9 12:30:09.451 2024] [1897622] binlog: replay stats: 36 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:09.451 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.022; 262.7 MB in 0.702 sec
[Tue Jul  9 12:30:09.451 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.023
[Tue Jul  9 12:30:10.119 2024] [1897622] binlog: table pile_super_all: recovered from tid 153746 to tid 153750
[Tue Jul  9 12:30:10.119 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1230106
[Tue Jul  9 12:30:10.119 2024] [1897622] binlog: replay stats: 113 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 2 tables
[Tue Jul  9 12:30:10.119 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.023; 256.2 MB in 0.667 sec
[Tue Jul  9 12:30:10.119 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.024
[Tue Jul  9 12:30:10.767 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1230238
[Tue Jul  9 12:30:10.767 2024] [1897622] binlog: replay stats: 132 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:10.767 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.024; 256.8 MB in 0.648 sec
[Tue Jul  9 12:30:10.767 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.025
[Tue Jul  9 12:30:11.456 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1230370
[Tue Jul  9 12:30:11.457 2024] [1897622] binlog: replay stats: 132 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:11.457 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.025; 256.4 MB in 0.689 sec
[Tue Jul  9 12:30:11.457 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.026
[Tue Jul  9 12:30:12.102 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1230502
[Tue Jul  9 12:30:12.102 2024] [1897622] binlog: replay stats: 132 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:12.102 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.026; 257.2 MB in 0.644 sec
[Tue Jul  9 12:30:12.102 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.027
[Tue Jul  9 12:30:12.745 2024] [1897622] binlog: table pile_all: skipped at tid 1230662 and max binlog tid 1230635
[Tue Jul  9 12:30:12.745 2024] [1897622] binlog: replay stats: 133 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables
[Tue Jul  9 12:30:12.745 2024] [1897622] binlog: finished replaying /var/lib/manticore/binlog/binlog.027; 256.3 MB in 0.643 sec
[Tue Jul  9 12:30:12.745 2024] [1897622] binlog: replaying log /var/lib/manticore/binlog/binlog.028
[Tue Jul  9 12:30:13.260 2024] [1897699] FATAL: out of memory (unable to allocate 5592400 bytes)
[Tue Jul  9 12:30:15.658 2024] [1896428] watchdog: main process 1897613 crashed via CRASH_EXIT (exit code 2), will be restarted
[Tue Jul  9 12:30:15.659 2024] [1896428] watchdog: main process 1898212 forked ok
[Tue Jul  9 12:30:15.659 2024] [1898212] DEBUG: config loaded, tables 1, clusters 0
[Tue Jul  9 12:30:15.660 2024] [1898212] Using local time zone '/etc/localtime'
[Tue Jul  9 12:30:15.660 2024] [1898212] DEBUG: StartGlobalWorkpool
[Tue Jul  9 12:30:15.666 2024] [1898212] starting daemon version '6.3.0 1811a9efb@24052209 (columnar 2.3.0 88a01c3@24052206) (secondary 2.3.0 88a01c3@24052206) (knn 2.3.0 88a01c3@24052206)' ...

Contents of /proc/[pid]/limits:

Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            83886080             83886080             bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             3095075              3095075              processes 
Max open files            524288               524288               files     
Max locked memory         unlimited            unlimited            bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       3095075              3095075              signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us

Manticore Search Version:

6.3.0

Operating System Version:

Ubuntu 22.04.3 LTS

Have you tried the latest development version?

No

Internal Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

- [ ] Implementation completed - [ ] Tests developed - [ ] Documentation updated - [ ] Documentation reviewed - [ ] Changelog updated
tomatolog commented 2 months ago

could you remove the binlog files and start again? maybe your binlog is corrupted

JubilantJerry commented 2 months ago

Removing the binlog files (indirectly by removing the tables from manticore.json) allowed my index to be usable again. But the first instance of the OOM was not even during replaying binlog files, and my server was not low on memory at that time. If this is not a true instance of running out of memory, what might the error originate from?

Logs from the first OOM:

[Tue Jul  9 06:50:19.187 2024] [283560] rt: table pile_all: diskchunk 65839(10376), segments 32  saved in 0.473534 (0.695903) sec, RAM saved/new 68210823/134525801 ratio 0.336450 (soft 
limit 45157611, conf limit 134217728)
[Tue Jul  9 06:50:19.517 2024] [283560] rt: table pile_all: diskchunk 65840(10377), segments 32  saved in 0.450257 (0.685808) sec, RAM saved/new 66431477/135477629 ratio 0.333333 (soft 
limit 44739197, conf limit 134217728)
[Tue Jul  9 06:50:19.837 2024] [283560] rt: table pile_all: diskchunk 65841(10378), segments 32  saved in 0.452416 (0.621195) sec, RAM saved/new 68094324/134264291 ratio 0.336503 (soft 
limit 45164696, conf limit 134217728)
[Tue Jul  9 06:50:20.161 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65842: prealloc failed: fai
led to mmap file '/var/lib/manticore/pile_all/pile_all.65842.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:20.347 2024] [283612] WARNING: rt: table pile_all failed to save disk chunk /var/lib/manticore/pile_all/pile_all.65844: failed to mmap file '/var/lib/manticore/pile_al
l/pile_all.65844.spidx.tmp.pgmvalues': Cannot allocate memory (length=4)
[Tue Jul  9 06:50:20.465 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65844.spidx.tmp.p
gmvalues': Cannot allocate memory (length=4)
[Tue Jul  9 06:50:20.686 2024] [283499] WARNING: last message repeated 1 times
[Tue Jul  9 06:50:20.686 2024] [283499] WARNING: rt: table pile_all failed to save disk chunk /var/lib/manticore/pile_all/pile_all.65845: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65845.spidx.tmp.pgmvalues': Cannot allocate memory (length=256000)
[Tue Jul  9 06:50:20.771 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65845.spidx.tmp.pgmvalues': Cannot allocate memory (length=256000)
[Tue Jul  9 06:50:21.445 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65846: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65846.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:21.805 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65847: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65847.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:22.128 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65848: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65848.spi': Cannot allocate memory (length=1488808)
[Tue Jul  9 06:50:22.490 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65849: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65849.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:22.884 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65850: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65850.spi': Cannot allocate memory (length=1520852)
[Tue Jul  9 06:50:23.286 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65851: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65851.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:23.744 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65853: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65853.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:24.321 2024] [283606] WARNING: last message repeated 1 times
[Tue Jul  9 06:50:24.321 2024] [283606] WARNING: rt: table pile_all failed to save disk chunk /var/lib/manticore/pile_all/pile_all.65855: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65855.spidx.tmp.pgmvalues': Cannot allocate memory (length=256000)
[Tue Jul  9 06:50:24.591 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65855.spidx.tmp.pgmvalues': Cannot allocate memory (length=256000)
[Tue Jul  9 06:50:25.079 2024] [283560] WARNING: last message repeated 1 times
[Tue Jul  9 06:50:25.079 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65856: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65856.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:25.242 2024] [283536] WARNING: rt common merge: table pile_all: failed to prealloc
[Tue Jul  9 06:50:25.588 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65857: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65857.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:25.588 2024] [283590] rt: table pile_all: optimized progressive chunk(s) 25879 ( left 10378 ) in 1d 3.6h
[Tue Jul  9 06:50:26.152 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65858: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65858.spa': Cannot allocate memory (length=3380208)
[Tue Jul  9 06:50:26.579 2024] [283511] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65859: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65859.spa': Cannot allocate memory (length=3380208)
sanikolaev commented 2 months ago

@JubilantJerry Can you please show docker inspect of your container when it's running and free -m ?

JubilantJerry commented 2 months ago

Currently (after I've deleted the binlogs and resolved the "out of memory" errors that prevented Manticore from starting), free -m gives:

               total        used        free      shared  buff/cache   available
Mem:          773845      533623       98422        4314      141799       89854
Swap:           2047        2024          23

I don't have the exact numbers from when the restarts were still happening but there was significantly more free memory than even this. Even with the above numbers, I wouldn't say the system is under memory pressure.

I installed Manticore directly with sudo apt install, it doesn't run in a docker container.

sanikolaev commented 2 months ago

Please show output of:

sudo cat /proc/`sudo cat /var/run/manticore/searchd.pid`/limits
JubilantJerry commented 2 months ago

Here is the output:

Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            83886080             83886080             bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             3095075              3095075              processes 
Max open files            524288               524288               files     
Max locked memory         unlimited            unlimited            bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       3095075              3095075              signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us  
sanikolaev commented 2 months ago

@JubilantJerry thanks. We've discussed this with the dev team and it looks really strange, especially Cannot allocate memory (length=4). Is it possible that you share your data files with us, so we can reproduce it locally? Here's how you can do it https://manual.manticoresearch.com/Reporting_bugs#Uploading-your-data

Best if you can first reproduce it with a lower data size. We'd also would need an instruction how to reproduce it.

Alternatively you can:

JubilantJerry commented 2 months ago

Unfortunately I'm not sure how to reproduce this. The workload is indeed completely writes, this happens during the process of building a 1.6TB index that has 1.2 billion rows. We build up this index with many INSERT calls in many threads. It takes about 2 days. Even then, we've done this about 10 times and only the most recent time did we encounter this OOM. I do have another machine to try things, but even if I reproduce it there, I don't think we can upload 1.6TB to S3. I have a suspicion that the problem fundamentally requires a large scale, for example if the root cause is some kind of integer or data structure overflow. Our script had already finished 85% of the inserts without issues, nothing special happened around the time of the OOM. I think it's worth noting that in the past we were making all the (non text) attributes columnar no_fast_fetch, and didn't get the OOM. In this run with the OOM, we stopped using columnar and we enabled index_field_lengths. If it's possible to share useful information even without uploading 1.6TB to S3, I can try running the whole process again on my other machine, and see if maybe it happens consistently with the non-columnar design of the index.

sanikolaev commented 2 months ago

Can you elaborate more on

INSERT calls in many threads

? Is it a thread pool with a fixed number of threads like you have 10 write threads and therefore there can't be more than 10 inserts trying to write to Manticore at once? Or does it work like you prepare a batch and send it to background no matter how many batches are already being uploaded?

JubilantJerry commented 2 months ago

Specifically it's a call to map in Python's multiprocessing.Pool. It's synchronous, our pool size was 128. Each worker in the pool performs a bulk insert with a batch of 100 rows. So there can be 128 simultaneous batch insert operations, but these all run to completion before new insert operations are made.

tomatolog commented 2 months ago

might be related https://github.com/manticoresoftware/dev/issues/141 to implement of the new mode for posting data into RT index

sanikolaev commented 2 months ago

@JubilantJerry can you share your full searchd log?

JubilantJerry commented 2 months ago

I think I have a way to consistently repro the problem now, though still not a repro that is completely independent. Today I observed that trying to resume the insert queries after the point of the last crash results in another "OOM".

My full searchd.log is 19GB, but I was able to bring it to 90MB with the command:

grep --text -v -e "empty binlog /var/lib/manticore/binlog" -e "binlog: replaying log" /var/log/manticore/searchd.log > /var/log/manticore/searchd2.log

Somehow, the file contains binary data too. Here are the contents: https://drive.google.com/file/d/1_WiBkoPZ-J7MBd-Afsx0HyKI8RRebNvj/view?usp=sharing

The most recent logs are: ``` [Thu Jul 11 18:36:35.480 2024] [3175804] rt: table pile_all: diskchunk 65905(10441), segments 32 saved in 0.463820 (0.626199) sec, RAM saved/new 66680820/136756550 ratio 0.333333 (soft limit 44739197, conf limit 134217728) [Thu Jul 11 18:36:35.854 2024] [3175804] rt: table pile_all: diskchunk 65906(10442), segments 32 saved in 0.599898 (0.694399) sec, RAM saved/new 68904967/135112841 ratio 0.337740 (soft limit 45330690, conf limit 134217728) [Thu Jul 11 18:36:36.214 2024] [3175804] rt: table pile_all: diskchunk 65907(10443), segments 32 saved in 0.575002 (0.732913) sec, RAM saved/new 67851583/135275208 ratio 0.334036 (soft limit 44833501, conf limit 134217728) [Thu Jul 11 18:36:36.606 2024] [3175804] rt: table pile_all: diskchunk 65908(10444), segments 32 saved in 0.550876 (0.750842) sec, RAM saved/new 67261258/135307355 ratio 0.333333 (soft limit 44739197, conf limit 134217728) [Thu Jul 11 18:36:36.843 2024] [3175736] WARNING: rt: table pile_all failed to save disk chunk /var/lib/manticore/pile_all/pile_all.65910: disk chunk /var/lib/manticore/pile_all/pile_al l.65909: prealloc failed: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65909.spe': Cannot allocate memory (length=360115) [Thu Jul 11 18:36:36.926 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65909: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65909.spe': Cannot allocate memory (length=360115) [Thu Jul 11 18:36:37.641 2024] [3175804] WARNING: last message repeated 1 times [Thu Jul 11 18:36:37.641 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65911: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65911.spe': Cannot allocate memory (length=349154) [Thu Jul 11 18:36:37.913 2024] [3175738] WARNING: rt: table pile_all failed to save disk chunk /var/lib/manticore/pile_all/pile_all.65913: failed to mmap file '/var/lib/manticore/pile_a ll/pile_all.65913.spidx.tmp.pgmvalues': Cannot allocate memory (length=4) [Thu Jul 11 18:36:38.031 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: failed to mmap file '/var/lib/manticore/pile_all/pile_all.65913.spidx.tmp. pgmvalues': Cannot allocate memory (length=4) [Thu Jul 11 18:36:38.738 2024] [3175804] WARNING: last message repeated 1 times [Thu Jul 11 18:36:38.738 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65914: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65914.spa': Cannot allocate memory (length=3380208) [Thu Jul 11 18:36:39.115 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65915: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65915.spe': Cannot allocate memory (length=366205) [Thu Jul 11 18:36:39.519 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65916: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65916.spe': Cannot allocate memory (length=357004) [Thu Jul 11 18:36:39.913 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65917: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65917.spa': Cannot allocate memory (length=3380208) [Thu Jul 11 18:36:40.344 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65918: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65918.spa': Cannot allocate memory (length=3380208) [Thu Jul 11 18:36:40.743 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65919: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65919.spa': Cannot allocate memory (length=3380208) [Thu Jul 11 18:36:41.177 2024] [3175804] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65920: prealloc failed: fa iled to mmap file '/var/lib/manticore/pile_all/pile_all.65920.spa': Cannot allocate memory (length=3380208) [Thu Jul 11 18:36:41.189 2024] [3175693] FATAL: out of memory (unable to allocate 5592400 bytes) [Thu Jul 11 18:36:47.205 2024] [3175691] watchdog: main process 3175692 crashed via CRASH_EXIT (exit code 2), will be restarted [Thu Jul 11 18:36:47.206 2024] [3175691] watchdog: main process 266669 forked ok [Thu Jul 11 18:36:47.211 2024] [266669] Using local time zone '/etc/localtime' [Thu Jul 11 18:36:47.219 2024] [266669] starting daemon version '6.3.0 1811a9efb@24052209 (columnar 2.3.0 88a01c3@24052206) (secondary 2.3.0 88a01c3@24052206) (knn 2.3.0 88a01c3@2405220 6)' ... [Thu Jul 11 18:36:47.220 2024] [266669] listening on 127.0.0.1:9312 for sphinx and http(s) [Thu Jul 11 18:36:47.220 2024] [266669] listening on 127.0.0.1:9306 for mysql [Thu Jul 11 18:36:47.220 2024] [266669] listening on 127.0.0.1:9308 for sphinx and http(s) [Thu Jul 11 18:37:39.710 2024] [266673] WARNING: table 'pile_super_all': disabled at the JSON config [Thu Jul 11 18:37:39.710 2024] [266673] WARNING: table 'pile_super_all': prealloc: disk chunk /var/lib/manticore/pile_super_all/pile_super_all.10848: prealloc failed: failed to mmap fil e '/var/lib/manticore/pile_super_all/pile_super_all.10848.spm': Cannot allocate memory (length=4000) - NOT SERVING [Thu Jul 11 18:37:39.714 2024] [266688] binlog: replaying log /var/lib/manticore/binlog/binlog.001 [Thu Jul 11 18:37:40.458 2024] [266698] binlog: table pile_test: recovered from tid 0 to tid 4 [Thu Jul 11 18:37:40.458 2024] [266698] binlog: table pile_all: skipped at tid 1231398 and max binlog tid 1230794 [Thu Jul 11 18:37:40.458 2024] [266698] binlog: replay stats: 136 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 2 tables [Thu Jul 11 18:37:40.458 2024] [266698] binlog: finished replaying /var/lib/manticore/binlog/binlog.001; 256.2 MB in 0.743 sec [Thu Jul 11 18:37:40.458 2024] [266698] binlog: replaying log /var/lib/manticore/binlog/binlog.006 [Thu Jul 11 18:37:41.485 2024] [266704] table 'pile_all': ramchunk saved. TID=1231419 [Thu Jul 11 18:37:41.485 2024] [266704] rt: table pile_all: diskchunk 65909(10445), segments 22 saved in 0.332187 (0.335439) sec, RAM saved/new 46371522/51472116 ratio 0.473935 (soft limit 63610475, conf limit 134217728) [Thu Jul 11 18:40:22.761 2024] [266704] table 'pile_all': ramchunk saved. TID=1231440 [Thu Jul 11 18:40:22.762 2024] [266704] rt: table pile_all: diskchunk 65910(10446), segments 21 saved in 0.311295 (161.319042) sec, RAM saved/new 45139449/7864920 ratio 0.851618 (soft limit 114302167, conf limit 134217728) [Thu Jul 11 18:40:23.042 2024] [266715] binlog: table pile_all: recovered from tid 1231398 to tid 1231461 [Thu Jul 11 18:40:23.042 2024] [266715] binlog: replay stats: 133 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables [Thu Jul 11 18:40:23.042 2024] [266715] binlog: finished replaying /var/lib/manticore/binlog/binlog.006; 257.3 MB in 162.583 sec [Thu Jul 11 18:40:23.042 2024] [266715] binlog: replaying log /var/lib/manticore/binlog/binlog.007 [Thu Jul 11 18:40:24.601 2024] [266694] table 'pile_all': ramchunk saved. TID=1231495 [Thu Jul 11 18:40:24.601 2024] [266694] rt: table pile_all: diskchunk 65911(10447), segments 25 saved in 0.785956 (0.788057) sec, RAM saved/new 115130212/87037626 ratio 0.569478 (soft limit 76434093, conf limit 134217728) [Thu Jul 11 18:40:24.612 2024] [266694] table 'pile_all': ramchunk saved. TID=1231504 [Thu Jul 11 18:40:24.612 2024] [266694] rt: table pile_all: diskchunk 65912(10448), segments 9 saved in 0.166000 (0.662729) sec, RAM saved/new 19454074/67583552 ratio 0.333333 (soft limit 44739197, conf limit 134217728) [Thu Jul 11 18:40:25.138 2024] [266689] table 'pile_all': ramchunk saved. TID=1231537 [Thu Jul 11 18:40:25.138 2024] [266689] rt: table pile_all: diskchunk 65913(10449), segments 32 saved in 0.519390 (0.522961) sec, RAM saved/new 67583552/69635005 ratio 0.492525 (soft limit 66105569, conf limit 134217728) [Thu Jul 11 18:40:25.244 2024] [266744] table 'pile_all': ramchunk saved. TID=1231557 [Thu Jul 11 18:40:25.244 2024] [266744] rt: table pile_all: diskchunk 65914(10450), segments 21 saved in 0.351691 (0.353581) sec, RAM saved/new 46084968/40404903 ratio 0.532837 (soft limit 71516116, conf limit 134217728) [Thu Jul 11 18:40:25.477 2024] [266718] binlog: table pile_all: recovered from tid 1231461 to tid 1231593 [Thu Jul 11 18:40:25.477 2024] [266718] binlog: replay stats: 132 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables [Thu Jul 11 18:40:25.477 2024] [266718] binlog: finished replaying /var/lib/manticore/binlog/binlog.007; 257.9 MB in 2.433 sec [Thu Jul 11 18:40:25.477 2024] [266718] binlog: replaying log /var/lib/manticore/binlog/binlog.008 [Thu Jul 11 18:40:25.969 2024] [266702] table 'pile_all': ramchunk saved. TID=1231592 [Thu Jul 11 18:40:25.969 2024] [266702] rt: table pile_all: diskchunk 65915(10451), segments 25 saved in 0.504577 (0.506930) sec, RAM saved/new 73125531/61910215 ratio 0.541527 (soft limit 72682551, conf limit 134217728) [Thu Jul 11 18:40:26.424 2024] [266771] table 'pile_all': ramchunk saved. TID=1231621 [Thu Jul 11 18:40:26.424 2024] [266771] rt: table pile_all: diskchunk 65916(10452), segments 25 saved in 0.455506 (0.457381) sec, RAM saved/new 61910215/83212912 ratio 0.426605 (soft limit 57257920, conf limit 134217728) [Thu Jul 11 18:40:26.938 2024] [266768] table 'pile_all': ramchunk saved. TID=1231655 [Thu Jul 11 18:40:26.938 2024] [266768] rt: table pile_all: diskchunk 65917(10453), segments 26 saved in 0.576149 (0.578581) sec, RAM saved/new 74470538/90662835 ratio 0.376605 (soft limit 50547033, conf limit 134217728) [Thu Jul 11 18:40:27.108 2024] [266726] table 'pile_all': ramchunk saved. TID=1231682 [Thu Jul 11 18:40:27.108 2024] [266726] rt: table pile_all: diskchunk 65918(10454), segments 24 saved in 0.441787 (0.444009) sec, RAM saved/new 57579199/64800727 ratio 0.470495 (soft limit 63148831, conf limit 134217728) [Thu Jul 11 18:40:27.209 2024] [266726] binlog: table pile_all: recovered from tid 1231593 to tid 1231725 [Thu Jul 11 18:40:27.209 2024] [266726] binlog: replay stats: 132 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables [Thu Jul 11 18:40:27.209 2024] [266726] binlog: finished replaying /var/lib/manticore/binlog/binlog.008; 257.3 MB in 1.731 sec [Thu Jul 11 18:40:27.209 2024] [266726] binlog: replaying log /var/lib/manticore/binlog/binlog.009 [Thu Jul 11 18:40:27.383 2024] [266768] table 'pile_all': ramchunk saved. TID=1231707 [Thu Jul 11 18:40:27.384 2024] [266768] rt: table pile_all: diskchunk 65919(10455), segments 25 saved in 0.360961 (0.362965) sec, RAM saved/new 51866021/69137469 ratio 0.428632 (soft limit 57530072, conf limit 134217728) [Thu Jul 11 18:40:27.784 2024] [266726] table 'pile_all': ramchunk saved. TID=1231737 [Thu Jul 11 18:40:27.784 2024] [266726] rt: table pile_all: diskchunk 65920(10456), segments 25 saved in 0.428472 (0.430624) sec, RAM saved/new 64629161/60988262 ratio 0.514492 (soft limit 69053949, conf limit 134217728) [Thu Jul 11 18:40:28.175 2024] [266793] table 'pile_all': ramchunk saved. TID=1231765 [Thu Jul 11 18:40:28.175 2024] [266793] rt: table pile_all: diskchunk 65921(10457), segments 25 saved in 0.412848 (0.415075) sec, RAM saved/new 59249033/70104668 ratio 0.458039 (soft limit 61476946, conf limit 134217728) [Thu Jul 11 18:40:28.673 2024] [266759] table 'pile_all': ramchunk saved. TID=1231798 [Thu Jul 11 18:40:28.674 2024] [266759] rt: table pile_all: diskchunk 65922(10458), segments 25 saved in 0.500255 (0.503080) sec, RAM saved/new 70104668/89674478 ratio 0.438760 (soft limit 58889345, conf limit 134217728) [Thu Jul 11 18:40:28.799 2024] [266788] binlog: table pile_all: recovered from tid 1231725 to tid 1231847 [Thu Jul 11 18:40:28.799 2024] [266788] binlog: replay stats: 122 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables [Thu Jul 11 18:40:28.799 2024] [266788] binlog: finished replaying /var/lib/manticore/binlog/binlog.009; 238.8 MB in 1.589 sec [Thu Jul 11 18:40:28.799 2024] [266788] binlog: finished replaying total 5 in 169.084 sec [Thu Jul 11 18:40:28.800 2024] [266679] prereading 4 tables [Thu Jul 11 18:40:29.631 2024] [266669] accepting connections [Thu Jul 11 18:40:29.783 2024] [266725] rt: table pile_all: diskchunk 65923(10459), segments 25 saved in 0.908782 (1.342079) sec, RAM saved/new 62052015/42337164 ratio 0.594430 (soft limit 79782986, conf limit 134217728) [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] started v2.3.10 '/usr/share/manticore/modules/manticore-buddy/bin/manticore-buddy --listen=http://127.0.0.1:9312 --bind=127.0.0.1 --threads=128 --skip=manticoresoftware/buddy-plugin-sharding --skip=manticoresoftware/buddy-plugin-queue' at http://127.0.0.1:38553 [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] Loaded plugins: [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] core: empty-string, backup, emulate-elastic, create, insert, alias, select, show, cli-table, plugin, test, alter-distributed-table, alter-rename-table, modify-table, knn, replace [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] local: [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] extra: [Thu Jul 11 18:40:30.971 2024] [266792] rt: table pile_all: diskchunk 65924(10460), segments 32 saved in 0.686553 (0.722751) sec, RAM saved/new 86816390/137872175 ratio 0.386385 (soft limit 51859775, conf limit 134217728) [Thu Jul 11 18:40:28.799 2024] [266788] binlog: table pile_all: recovered from tid 1231725 to tid 1231847 [Thu Jul 11 18:40:28.799 2024] [266788] binlog: replay stats: 122 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 1 tables [Thu Jul 11 18:40:28.799 2024] [266788] binlog: finished replaying /var/lib/manticore/binlog/binlog.009; 238.8 MB in 1.589 sec [Thu Jul 11 18:40:28.799 2024] [266788] binlog: finished replaying total 5 in 169.084 sec [Thu Jul 11 18:40:28.800 2024] [266679] prereading 4 tables [Thu Jul 11 18:40:29.631 2024] [266669] accepting connections [Thu Jul 11 18:40:29.783 2024] [266725] rt: table pile_all: diskchunk 65923(10459), segments 25 saved in 0.908782 (1.342079) sec, RAM saved/new 62052015/42337164 ratio 0.594430 (soft limit 79782986, conf limit 134217728) [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] started v2.3.10 '/usr/share/manticore/modules/manticore-buddy/bin/manticore-buddy --listen=http://127.0.0.1:9312 --bind=127.0.0.1 --threads=128 --skip=manticoresoftware/buddy-plugin-sharding --skip=manticoresoftware/buddy-plugin-queue' at http://127.0.0.1:38553 [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] Loaded plugins: [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] core: empty-string, backup, emulate-elastic, create, insert, alias, select, show, cli-table, plugin, test, alter-distributed-table, alter-rename-table, modify-table, knn, replace [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] local: [Thu Jul 11 18:40:30.218 2024] [266673] [BUDDY] extra: [Thu Jul 11 18:40:30.971 2024] [266792] rt: table pile_all: diskchunk 65924(10460), segments 32 saved in 0.686553 (0.722751) sec, RAM saved/new 86816390/137872175 ratio 0.386385 (soft limit 51859775, conf limit 134217728) [Thu Jul 11 18:40:31.268 2024] [266792] rt: table pile_all: diskchunk 65925(10461), segments 32 saved in 0.539561 (0.722477) sec, RAM saved/new 68725617/136970012 ratio 0.334113 (soft limit 44843909, conf limit 134217728) [Thu Jul 11 18:40:31.562 2024] [266792] rt: table pile_all: diskchunk 65926(10462), segments 32 saved in 0.494821 (0.580027) sec, RAM saved/new 69146558/135549326 ratio 0.337801 (soft limit 45338937, conf limit 134217728) [Thu Jul 11 18:40:31.809 2024] [266792] rt: table pile_all: diskchunk 65927(10463), segments 32 saved in 0.467726 (0.539097) sec, RAM saved/new 67823454/115886080 ratio 0.369189 (soft limit 49551646, conf limit 134217728) [Thu Jul 11 18:40:32.153 2024] [266795] rt: table pile_all: diskchunk 65928(10464), segments 32 saved in 0.474879 (0.569570) sec, RAM saved/new 67725872/78271428 ratio 0.463884 (soft limit 62261512, conf limit 134217728) [Thu Jul 11 18:40:32.280 2024] [266679] preread 4 tables in 3.479 sec [Thu Jul 11 18:40:32.313 2024] [266691] rt: table pile_all: diskchunk 65929(10465), segments 29 saved in 0.446381 (0.448279) sec, RAM saved/new 61054158/43033680 ratio 0.586564 (soft limit 78727260, conf limit 134217728) [Fri Jul 12 04:37:35.608 2024] [266775] rt: table pile_test: ramchunk saved ok (mode=periodic, last TID=0, current TID=4, ram=0.001 Mb, time delta=35995 sec, took=0.028 sec) [Fri Jul 12 04:37:35.731 2024] [266723] rt: table pile_all: ramchunk saved ok (mode=periodic, last TID=1232025, current TID=1232051, ram=53.636 Mb, time delta=35823 sec, took=0.150 sec) [Fri Jul 12 10:21:54.434 2024] [266719] rt: table pile_all: diskchunk 74527(1869), segments 23 forcibly saved in 0.392508 (0.395950) sec, RAM saved/new 55948268/0 ratio 0.950000 (soft limit 127506841, conf limit 134217728) [Fri Jul 12 10:30:31.421 2024] [266669] caught SIGTERM, shutting down [Fri Jul 12 10:30:31.423 2024] [266771] WARNING: conn 127.0.0.1:42826(104), sock=104720: failed to receive HTTP request, AsyncNetInputBuffer_c::AppendData: got SIGTERM, return -1 [Fri Jul 12 10:30:31.695 2024] [266732] WARNING: rt common merge: table pile_all: failed to merge /var/lib/manticore/pile_all/pile_all.73786 (interrupted because of shutdown) [Fri Jul 12 10:30:31.696 2024] [266732] WARNING: rt: table pile_all: optimization terminated chunk(s) 8622 ( left 1844 ) in 15h 50m [Fri Jul 12 10:30:32.269 2024] [266711] rt: table pile_all: ramchunk saved in 0.002 sec [Fri Jul 12 10:30:44.019 2024] [266711] rt: table temp: ramchunk saved in 0.001 sec [Fri Jul 12 10:30:44.947 2024] [266669] shutdown daemon version '6.3.0 1811a9efb@24052209 (columnar 2.3.0 88a01c3@24052206) (secondary 2.3.0 88a01c3@24052206) (knn 2.3.0 88a01c3@24052206) (buddy v2.3.10)' ... [Fri Jul 12 10:30:44.948 2024] [266669] shutdown complete [Fri Jul 12 10:30:45.569 2024] [3175691] watchdog: main process 266669 exited cleanly (exit code 0), shutting down ```
I see a lot of overflowed integers when checking `show table pile_all status` and `show table pile_super_all status`: ``` MySQL [(none)]> show table pile_all status; +-------------------------------+--------------------------------------------------------------------------+ | Variable_name | Value | +-------------------------------+--------------------------------------------------------------------------+ | index_type | rt | | indexed_documents | 1232286000 | | indexed_bytes | 1451919922754 | | field_tokens_content | 104431031188850569 | | field_tokens_sid | -9068919954860747616 | | field_tokens_sid_div_2 | -9068919954860747616 | | field_tokens_sid_div_4 | -9068919954860747616 | | field_tokens_sid_div_8 | -9068919954860747616 | | field_tokens_sid_div_16 | -9068919954860747616 | | field_tokens_sid_div_32 | -9068919953877632616 | | field_tokens_sid_div_64 | -9068919952894517616 | | field_tokens_sid_div_128 | -9068919952894517616 | | field_tokens_sid_div_256 | -9068919952894517616 | | field_tokens_sid_div_512 | -9068919952894517616 | | field_tokens_sid_div_1024 | -9068919952894517616 | | field_tokens_sid_div_2048 | -9068919952894517616 | | field_tokens_sid_div_4096 | -9068919952894517616 | | field_tokens_sid_div_8192 | -9068919952894517616 | | field_tokens_sid_div_16384 | -9068919952894517616 | | field_tokens_sid_div_constant | -9068919952894517616 | | total_tokens | 2575664363738716641 | | ram_bytes | 187992513896 | | disk_bytes | 1504543283813 | | disk_mapped | 222924089630 | | disk_mapped_cached | 187988262912 | | disk_mapped_doclists | 0 | | disk_mapped_cached_doclists | 0 | | disk_mapped_hitlists | 0 | | disk_mapped_cached_hitlists | 0 | | killed_documents | 0 | | killed_rate | 0.00% | | ram_chunk | 0 | | ram_chunk_segments_count | 0 | | disk_chunks | 1844 | | mem_limit | 134217728 | | mem_limit_rate | 33.33% | | ram_bytes_retired | 0 | | locked | 0 | | tid | 1232051 | | tid_saved | 1232051 | | query_time_1min | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | query_time_5min | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | query_time_15min | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | query_time_total | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | found_rows_1min | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | found_rows_5min | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | found_rows_15min | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | | found_rows_total | {"queries":0, "avg":"-", "min":"-", "max":"-", "pct95":"-", "pct99":"-"} | +-------------------------------+--------------------------------------------------------------------------+ 48 rows in set (6.451 sec) ``` ``` MySQL [(none)]> show table pile_super_all status; +-------------------------------+--------------------------------------------------------------------------------------------------------+ | Variable_name | Value | +-------------------------------+--------------------------------------------------------------------------------------------------------+ | index_type | rt | | indexed_documents | 153994000 | | indexed_bytes | 739654896493 | | field_tokens_content | 17825380327969023 | | field_tokens_sid | 23457556186000 | | field_tokens_sid_div_2 | 23457556186000 | | field_tokens_sid_div_4 | 23457556186000 | | field_tokens_sid_div_8 | 23457556186000 | | field_tokens_sid_div_16 | 23457556186000 | | field_tokens_sid_div_32 | 23457556186000 | | field_tokens_sid_div_64 | 23457556186000 | | field_tokens_sid_div_128 | 23457556186000 | | field_tokens_sid_div_256 | 23457556186000 | | field_tokens_sid_div_512 | 23457556186000 | | field_tokens_sid_div_1024 | 23457556186000 | | field_tokens_sid_div_2048 | 23457556186000 | | field_tokens_sid_div_4096 | 23457556186000 | | field_tokens_sid_div_8192 | 23457556186000 | | field_tokens_sid_div_16384 | 23457556186000 | | field_tokens_sid_div_constant | 23457556186000 | | total_tokens | 18200701226945023 | | ram_bytes | 40305267560 | | disk_bytes | 815599614397 | | disk_mapped | 40301977120 | | disk_mapped_cached | 40304652288 | | disk_mapped_doclists | 0 | | disk_mapped_cached_doclists | 0 | | disk_mapped_hitlists | 0 | | disk_mapped_cached_hitlists | 0 | | killed_documents | 0 | | killed_rate | 0.00% | | ram_chunk | 0 | | ram_chunk_segments_count | 0 | | disk_chunks | 266 | | mem_limit | 134217728 | | mem_limit_rate | 33.33% | | ram_bytes_retired | 0 | | locked | 0 | | tid | 154000 | | tid_saved | 154000 | | query_time_1min | {"queries":1, "avg_sec":0.002, "min_sec":0.002, "max_sec":0.002, "pct95_sec":0.002, "pct99_sec":0.002} | | query_time_5min | {"queries":1, "avg_sec":0.002, "min_sec":0.002, "max_sec":0.002, "pct95_sec":0.002, "pct99_sec":0.002} | | query_time_15min | {"queries":1, "avg_sec":0.002, "min_sec":0.002, "max_sec":0.002, "pct95_sec":0.002, "pct99_sec":0.002} | | query_time_total | {"queries":1, "avg_sec":0.002, "min_sec":0.002, "max_sec":0.002, "pct95_sec":0.002, "pct99_sec":0.002} | | found_rows_1min | {"queries":1, "avg":1, "min":1, "max":1, "pct95":1, "pct99":1} | | found_rows_5min | {"queries":1, "avg":1, "min":1, "max":1, "pct95":1, "pct99":1} | | found_rows_15min | {"queries":1, "avg":1, "min":1, "max":1, "pct95":1, "pct99":1} | | found_rows_total | {"queries":1, "avg":1, "min":1, "max":1, "pct95":1, "pct99":1} | +-------------------------------+--------------------------------------------------------------------------------------------------------+ 48 rows in set (0.064 sec) ```

The total_tokens number is definitely many orders of magnitude larger than the actual count.

I will need to drop the index and revert to the columnar design by tomorrow to stay on schedule with my project. If there's any more information that might be useful to provide before I do that, please let me know.

sanikolaev commented 2 months ago

The total_tokens number is definitely many orders of magnitude larger than the actual count.

Right. We'll discuss what are the limits there and the chance to overflow.

Another kind of edge case is:

[Tue Jul  9 06:50:25.588 2024] [283590] rt: table pile_all: optimized progressive chunk(s) 25879 ( left 10378 ) in 1d 3.6h

I'm afraid 25K disk chunks is not something we've ever tested yet, nor do most users deal with such a large number. Additionally, given that merging them took 27 hours and there are still another 10K chunks left, which would probably take another half a day to complete, it might make sense to significantly increase the rt_mem_limit to reduce the load from merging. Even though segment merging in the RAM chunk may take longer, which will slow down the inserts, overall it may still be beneficial since the maximum number of accumulated chunks will be lower, thereby reducing the load from merging them. Also, this issue might be somehow related to the memory allocation problem.

I also see that the first mem allocation issue in the provided searchd log was at:

[Tue Jul  9 06:50:20.161 2024] [283560] WARNING: rt: table pile_all failed to load disk chunk after RAM save: disk chunk /var/lib/manticore/pile_all/pile_all.65842: prealloc failed: failed to mm
ap file '/var/lib/manticore/pile_all/pile_all.65842.spa': Cannot allocate memory (length=3380208)

i.e. at the same minute when the merging of 25K disk chunks completed. Since then there were many mem allocation issues, but there were at least 10K disk chunks left to merge and I'm thinking if it can be a sign of a strong correlation between the mem issue and the high number of disk chunks.

[Tue Jul 9 10:07:28.976 2024] [1742768] starting daemon version '6.3.0 1811a9efb@24052209 (columnar 2.3.0 88a01c3@24052206) (secondary 2.3.0 88a01c3@24052206) (knn 2.3.0 88a01c3@24052206)' ...

We released 6.3.2 with 10+ bug fixes. Not sure it can help, but I recommend upgrading.

| ram_bytes                     | 187992513896                                                             |
...
| disk_mapped                   | 222924089630                                                             |
| disk_mapped_cached            | 187988262912                                                             |
...
| ram_bytes                     | 40305267560                                                                                            |
...
| disk_mapped                   | 40301977120                                                                                            |
| disk_mapped_cached            | 40304652288                                                                                            |

ram_bytes: 187992513896 + 40305267560 = 212 GB disk_mapped: 222924089630 + 40301977120 = 245 GB disk_mapped_cached: 187988262912 + 40304652288 = 213 GB

So the RAM requirements then were 245GB with 212GB being resident in RAM.

When reproducing the issue, I would first try out the 25K disk chunks hypothesis: