Skip to content

[Bug]: fulltext index search 500 threads report 'Communications link failure'. #21418

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

3742ad8

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

Image

log:https://shanghai.idc.matrixorigin.cn:30001/explore?panes=%7B%22GYP%22:%7B%22datasource%22:%22loki%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bhost%3D%5C%2210-222-1-129%5C%22%7D%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22loki%22%7D,%22editorMode%22:%22builder%22%7D%5D,%22range%22:%7B%22from%22:%221739961168000%22,%22to%22:%221739961519000%22%7D%7D%7D&schemaVersion=1&orgId=1

Expected Behavior

No response

Steps to Reproduce

1.
CREATE TABLE `test` (
  `id` int NOT NULL,
  `title` varchar(255) DEFAULT NULL,
  `content` text DEFAULT NULL,
  PRIMARY KEY (`id`),
 FULLTEXT `f01`(`content`)
);

load data local infile '/root/weilu/zhwiki-latest-pages-articles-multistream6.xml-p7096380p8596379.csv' into table test fields terminated by ',' enclosed by '"' escaped by '';

2. 
cd mo-load/cases/fulltext
vi case.yml
name: "fulltext_test"
runMins: 5
runTimes: 0
transaction:
  - name: "fulltext_test"
    terminal: 10
    scripts:
      - sql: "SELECT * from test.test where match(content) against ('{str1}' in natural language mode) order by id desc limit 100;"
        
vi replace.yml
replace:
  - name: str1
    type: file
    path: /root/weilu/mo-load/replace/temp_fulltext_output.txt
    dtype: "varchar"


./run.sh -c cases/fulltext -b test -t 500

load file and temp_fulltext_output.txt, please contact me privately.

Additional information

No response

Activity

  1. added
    kind/bug
    severity/s0
    on Feb 19, 2025
  2. added this to the 2.1.0 milestone on Feb 19, 2025
  3. Ariznawlll commented on Feb 24, 2025

    @Ariznawlll
    CollaboratorAuthor

    repro:

    commit:35b8ac3f37723e1ae7a0d3fe1b08d6fda0657e71

    oom:
    Image

    Image
    1.
    CREATE TABLE `test` (
      `id` int NOT NULL,
      `title` varchar(255) DEFAULT NULL,
      `content` text DEFAULT NULL,
      PRIMARY KEY (`id`),
     FULLTEXT `f01`(`content`)
    );
    
    load data local infile '/root/weilu/zhwiki-latest-pages-articles-multistream6.xml-p7096380p8596379.csv' into table test fields terminated by ',' enclosed by '"' escaped by '';
    
    2. 
    cd mo-load/cases/fulltext
    vi case.yml
    name: "fulltext_test"
    runMins: 5
    runTimes: 0
    transaction:
      - name: "fulltext_test"
        terminal: 10
        scripts:
          - sql: "SELECT * from test.test where match(content) against ('{str1}' in natural language mode) order by id desc limit 100;"
            
    vi replace.yml
    replace:
      - name: str1
        type: file
        path: /root/weilu/mo-load/replace/keyword_100.txt
        dtype: "varchar"
    
    
    ./run.sh -c cases/fulltext -b test -t 500
    

    load file and keyword_100.txt, please contact me privately.

    heap profile:
    heap_profile0224-2.zip

    malloc profile:
    malloc_profile0224-2.zip

    log:https://shanghai.idc.matrixorigin.cn:30001/explore?panes=%7B%22_Z-%22:%7B%22datasource%22:%22loki%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bhost%3D%5C%2210-222-1-129%5C%22%7D%20%7C%3D%20%60%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22loki%22%7D,%22editorMode%22:%22builder%22%7D%5D,%22range%22:%7B%22from%22:%221740378300000%22,%22to%22:%221740379020000%22%7D%7D%7D&schemaVersion=1&orgId=1

  4. ouyuanning commented on Mar 7, 2025

    @ouyuanning
    Contributor

    本地跑了一下。50线程的。
    堆内内存占用:

    Image

    对外内存占用:

    Image

  5. ouyuanning commented on Mar 7, 2025

    @ouyuanning
    Contributor

    该测试中,总共会执行的sql如下(假设搜索的”是“这个字符):

    -- 测试的sql
    SELECT * from test where match(content) against ('是' in natural language mode) order by id desc limit 100;
    
    -- 其中fulltext内部执行的sql:
    SELECT COUNT(*), AVG(pos) from `db1`.`__mo_index_secondary_01956eb3-20aa-79ac-bf87-2f8ce7ea5d59` where word = '__DocLen'; -- 拿doc len,排序算法用
    SELECT doc_id, CAST(0 as int) FROM `db1`.`__mo_index_secondary_01956eb3-20aa-79ac-bf87-2f8ce7ea5d59` WHERE prefix_eq(word,'是'); -- 拿包含”是“的doc_id列表
    

    这3个SQL之后第一个SQL有join,起执行计划如下:

    mysql> explain analyze SELECT * from test where match(content) against ('是' in natural language mode) order by id desc limit 100;
    +----------------------------------------------------------------------------------------------------------------------------------------------------------+
    | tp query plan                                                                                                                                            |
    +----------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Project                                                                                                                                                  |
    |   Analyze: timeConsumed=0ms waitTime=0ms inputRows=100 outputRows=100 InputSize=11mb OutputSize=11mb MemorySize=11mb                                     |
    |   ->  Sort                                                                                                                                               |
    |         Analyze: timeConsumed=12ms waitTime=0ms inputRows=2223 outputRows=100 InputSize=5mb OutputSize=11mb MemorySize=11mb                              |
    |         Sort Key: test.id DESC                                                                                                                           |
    |         Limit: 100                                                                                                                                       |
    |         Send Message: [tag 2 , type MsgTopValue]                                                                                                         |
    |         ->  Join                                                                                                                                         |
    |               Analyze: timeConsumed=26ms waitTime=0ms inputRows=197117 outputRows=2223 InputSize=7mb OutputSize=5mb MemorySize=16mb                      |
    |               Join Type: INNER                                                                                                                           |
    |               Join Cond: (test.id = mo_fulltext_alias_0.doc_id)                                                                                          |
    |               Runtime Filter Build: #[-1,0]                                                                                                              |
    |               ->  Table Scan on db1.test                                                                                                                 |
    |                     Analyze: timeConsumed=11ms waitTime=0ms inputBlocks=1 inputRows=4606 outputRows=4606 InputSize=6mb OutputSize=6mb MemorySize=13mb    |
    |                     Sort Key: id DESC                                                                                                                    |
    |                     Runtime Filter Probe: test.id                                                                                                        |
    |                     Recv Message: [tag 2 , type MsgTopValue]                                                                                             |
    |               ->  Table Function on fulltext_index_scan                                                                                                  |
    |                     Analyze: timeConsumed=352ms waitTime=0ms inputRows=0 outputRows=192511 InputSize=0bytes OutputSize=770044bytes MemorySize=32768bytes |
    +----------------------------------------------------------------------------------------------------------------------------------------------------------+
    

    内存占用大的根本原因是:
    1、Table Scan on db1.test 拿的数据较多。 这里有4606行
    2、这个是select * ,而该表的 content 列是测试的字符串,这个列较大

    测试看MO在join没有内存泄露。暂时没有太好的方法优化这种情况下join的内存占用。建议测试SQL修改为:

    SELECT * from test where match(content) against ('是' in natural language mode) limit 100;
    

    没有order by的话,优化器可以让join只拿尽量少的数据,以减少内存占用

    mysql> explain analyze SELECT * from test where match(content) against ('是' in natural language mode) limit 100;
    +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | ap query plan on one cn(10 core)                                                                                                                                             |
    +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Project                                                                                                                                                                      |
    |   Analyze: timeConsumed=0ms waitTime=0ms inputRows=100 outputRows=100 InputSize=396691bytes OutputSize=396691bytes MemorySize=396691bytes                                    |
    |   ->  Sort                                                                                                                                                                   |
    |         Analyze: timeConsumed=0ms waitTime=0ms inputRows=100 outputRows=100 InputSize=397091bytes OutputSize=396691bytes MemorySize=793782bytes                              |
    |         Sort Key: mo_fulltext_alias_0.score DESC                                                                                                                             |
    |         ->  Join                                                                                                                                                             |
    |               Analyze: timeConsumed=0ms waitTime=0ms inputRows=200 outputRows=100 InputSize=397491bytes OutputSize=397091bytes MemorySize=33682bytes                         |
    |               Join Type: INNER                                                                                                                                               |
    |               Join Cond: (test.id = mo_fulltext_alias_0.doc_id)                                                                                                              |
    |               Runtime Filter Build: #[-1,0]                                                                                                                                  |
    |               Limit: 100                                                                                                                                                     |
    |               ->  Table Scan on db1.test                                                                                                                                     |
    |                     Analyze: timeConsumed=905ms waitTime=0ms inputBlocks=55 inputRows=100 outputRows=100 InputSize=396691bytes OutputSize=396691bytes MemorySize=138674bytes |
    |                     Runtime Filter Probe: test.id                                                                                                                            |
    |               ->  Table Function on fulltext_index_scan                                                                                                                      |
    |                     Analyze: timeConsumed=273ms waitTime=0ms inputRows=0 outputRows=100 InputSize=0bytes OutputSize=800bytes MemorySize=65536bytes                           |
    |                     Limit: 100                                                                                                                                               |
    +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    
  6. ouyuanning commented on Mar 7, 2025

    @ouyuanning
    Contributor

    应该还有另外一个问题就是 select * 返回的内容太多了。数据传输也太多。因为我测试

    select * from test;
    

    tps也是0,根本跑步上去。

    select id from test;
    

    tps可以跑到5200左右。

    所以可能建议这样测:(虽然tps也很差,但是这样起码应该是fulltext的问题了)

    SELECT id from test where match(content) against ('是' in natural language mode) limit 100;
    
  7. ouyuanning commented on Mar 14, 2025

    @ouyuanning
    Contributor

    已经跟#21414一起处理

  8. modified the milestones: 2.1.0, 2505 on Apr 27, 2025
  9. Ariznawlll commented on May 30, 2025

    @Ariznawlll
    CollaboratorAuthor

    main commit:5cc42fe

    测试步骤:
    1.
    CREATE TABLE `test` (
      `id` int NOT NULL,
      `title` varchar(255) DEFAULT NULL,
      `content` text DEFAULT NULL,
      PRIMARY KEY (`id`),
     FULLTEXT `f01`(`content`)
    );
    
    load data local infile '/root/weilu/zhwiki-latest-pages-articles-multistream6.xml-p7096380p8596379.csv' into table test fields terminated by ',' enclosed by '"' escaped by '';
    
    2. 
    cd mo-load/cases/fulltext
    vi case.yml
    name: "fulltext_test"
    runMins: 5
    runTimes: 0
    transaction:
      - name: "fulltext_test"
        terminal: 10
        scripts:
          - sql: "SELECT * from test.test where match(content) against ('{str1}' in natural language mode) order by id desc limit 100;"
            
    vi replace.yml
    replace:
      - name: str1
        type: file
        path: /root/weilu/mo-load/replace/temp_fulltext_output.txt
        dtype: "varchar"
    
    
    ./run.sh -c cases/fulltext -b test -t 500
    load file and temp_fulltext_output.txt, please contact me privately.
    
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugphase/testingseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions