Skip to content

[Bug] explain data change on operatorMem, mpp22698 test failed #295

Closed

Description

@congxuebin

Cloudberry Database version

No response

What happened

Issue the following statements:

SET gp_resqueue_print_operator_memory_limits=on;
SET gp_resqueue_memory_policy_auto_fixed_mem=100;
create table mpp22698(c1 int, c2 int) partition by range(c2) (start(1) end(6) every(1));
select get_operator_mem('explain select * from mpp22698;');


You will get the following:

NOTICE: One or more columns in the following table(s) do not have statistics: mpp22698
HINT: For non-partitioned tables, run analyze <table_name>(<column_list>). For partitioned tables, run analyze rootpartition <table_name>(<column_list>). See log for columns missing statistics.
ERROR: IndexError: list index out of range
CONTEXT: Traceback (most recent call last):
PL/Python function "get_operator_mem", line 8, in
list_opermem.add(operatorMemStr.split(':')[1])
PL/Python function "get_operator_mem"


But test case expects the following:

get_operator_mem  
--------------------
 ['100 kB']
(1 row)

What you think should happen instead

No response

How to reproduce

As mentioned above

Operating System

centos7

Anything else

No response

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

Activity

  1. avamingli commented on Nov 10, 2023

    @avamingli
    Contributor

    Hi, I try to repeoduce but failed, get_operator_mem doesn't exist in CBDB,

    gpadmin=# select get_operator_mem('explain select * from mpp22698;');
    ERROR:  function get_operator_mem(unknown) does not exist
    LINE 1: select get_operator_mem('explain select * from mpp22698;');
                   ^
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

    Could you provide a complete case?

  2. my-ship-it commented on Nov 10, 2023

    @my-ship-it
    Contributor
  3. avamingli commented on Nov 10, 2023

    @avamingli
    Contributor

    NOTICE: One or more columns in the following table(s) do not have statistics: mpp22698
    HINT: For non-partitioned tables, run analyze <table_name>(<column_list>). For partitioned tables, run analyze rootpartition <table_name>(<column_list>). See log for columns missing statistics.
    ERROR: IndexError: list index out of range
    CONTEXT: Traceback (most recent call last):
    PL/Python function "get_operator_mem", line 8, in
    list_opermem.add(operatorMemStr.split(':')[1])
    PL/Python function "get_operator_mem"

    According to the message: it's not a statistic issue(just a notice and hint).

    It shows the real errors are inside PL/Python function "get_operator_mem", a related pr #292 has fixed sth about operatorMem in explain output.
    I think this is not a CBDB bug, change out-side-of CBDB's functionget_operator_mem according the the explain output will resolve your issue.

  4. congxuebin commented on Nov 10, 2023

    @congxuebin
    ContributorAuthor

    The following is DDL of this function. I believe something changed caused this failure.

    create or replace function get_operator_mem(query text) returns text as
    $$
    rv = plpy.execute(query)
    list_opermem = set()
    for i in range(len(rv)):
    cur_line = rv[i]['QUERY PLAN']
    if 'operatorMem' in cur_line or 'Function Scan on gp_partition_expansion' in cur_line or 'Function Scan on gp_partition_inverse' in cur_line:
    operatorMemStr = cur_line[cur_line.rindex(')'):]
    list_opermem.add(operatorMemStr.split(':')[1])
    return list(list_opermem)
    $$
    language plpython3u;

  5. congxuebin commented on Nov 10, 2023

    @congxuebin
    ContributorAuthor

    @avamingli Oh, ok. Let me look into the function. Will get back to you for confirmation. If it is an incompatible change, I would update test case accordingly.

  6. congxuebin commented on Nov 10, 2023

    @congxuebin
    ContributorAuthor

    I spoke with Mingli and confirmed this is as designed.

    The following is more details I identified:

    New behavior:

    Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8) (operatorMem: 100kB)
    ...

    Old behavior:

    Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8) operatorMem: 100kB

    That is why Python PL failed.

    operatorMemStr = cur_line[cur_line.rindex(')'):]
    list_opermem.add(operatorMemStr.split(':')[1])

    Gonna change test case to fix it. Closing this issue.

  7. changed the title [-][Bug] Unexpected missing statistics, mpp22698 test failed[/-] [+][Bug] explain data change on operatorMem, mpp22698 test failed[/+] on Nov 10, 2023
  8. added a commit that references this issue on Mar 10, 2026
  9. added a commit that references this issue on Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: BugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions