citusdata / citus

Distributed PostgreSQL as an extension
https://www.citusdata.com
GNU Affero General Public License v3.0
10.56k stars 668 forks source link

"ERROR: cache lookup failed for type 0" when joining two append tables #3086

Open onlined opened 5 years ago

onlined commented 5 years ago

I have two workers, these tables and data:

CREATE TABLE part
(
    p_partkey     INTEGER not null,
    p_name        VARCHAR(55) not null,
    p_mfgr        CHAR(25) not null,
    p_brand       CHAR(10) not null,
    p_type        VARCHAR(25) not null,
    p_size        INTEGER not null,
    p_container   CHAR(10) not null,
    p_retailprice DOUBLE PRECISION not null,
    p_comment     VARCHAR(23) not null
);

select create_distributed_table('part', 'p_partkey', 'append');

CREATE TABLE lineitem
(
    l_orderkey    BIGINT not null,
    l_partkey     INTEGER not null,
    l_suppkey     INTEGER not null,
    l_linenumber  INTEGER not null,
    l_quantity    DOUBLE PRECISION not null,
    l_extendedprice  DOUBLE PRECISION not null,
    l_discount    DOUBLE PRECISION not null,
    l_tax         DOUBLE PRECISION not null,
    l_returnflag  CHAR(1) not null,
    l_linestatus  CHAR(1) not null,
    l_shipdate    DATE not null,
    l_commitdate  DATE not null,
    l_receiptdate DATE not null,
    l_shipinstruct CHAR(25) not null,
    l_shipmode     CHAR(10) not null,
    l_comment      VARCHAR(44) not null
);

select create_distributed_table('lineitem', 'l_orderkey', 'append');

lineitem.tbl:

1|155190|7706|1|17|21168.23|0.04|0.02|N|O|1996-03-13|1996-02-12|1996-03-22|DELIVER IN PERSON|TRUCK|egular courts above the
1|67310|7311|2|36|45983.16|0.09|0.06|N|O|1996-04-12|1996-02-28|1996-04-20|TAKE BACK RETURN|MAIL|ly final dependencies: slyly bold 

When I run this query, I get the error:

psql> SELECT * FROM part, lineitem WHERE p_partkey = l_partkey;
ERROR: cache lookup failed for type 0
marcocitus commented 5 years ago

Stack trace:

#0  errstart (elevel=elevel@entry=20, filename=0xaaf220 "lsyscache.c", lineno=2057, funcname=0xaaf4e0 <__func__.23934> "get_typlenbyvalalign", domain=domain@entry=0x0)
    at elog.c:251
#1  0x00000000008a90cf in elog_finish (elevel=elevel@entry=20, fmt=fmt@entry=0x8f5ae8 "cache lookup failed for type %u") at elog.c:1358
#2  0x0000000000890fe7 in get_typlenbyvalalign (typid=typid@entry=0, typlen=typlen@entry=0x7ffecce6575c, typbyval=typbyval@entry=0x7ffecce6575f, 
    typalign=typalign@entry=0x7ffecce6575e "") at lsyscache.c:2057
#3  0x00007f85c72078c1 in SplitPointObject (shardIntervalArray=0x0, shardIntervalCount=0) at planner/multi_physical_planner.c:1950
#4  0x00007f85c7209310 in MapTaskList (mapMergeJob=mapMergeJob@entry=0x220fe68, filterTaskList=filterTaskList@entry=0x219d558) at planner/multi_physical_planner.c:4224
#5  0x00007f85c7209ab2 in BuildJobTreeTaskList (jobTree=0x2218070, plannerRestrictionContext=plannerRestrictionContext@entry=0x21ee998) at planner/multi_physical_planner.c:2052
#6  0x00007f85c7209b17 in CreatePhysicalDistributedPlan (multiTree=multiTree@entry=0x220ff00, plannerRestrictionContext=plannerRestrictionContext@entry=0x21ee998)
    at planner/multi_physical_planner.c:222
#7  0x00007f85c71f79bc in CreateDistributedPlan (planId=planId@entry=3, originalQuery=originalQuery@entry=0x2032110, query=query@entry=0x2032228, 
    boundParams=boundParams@entry=0x0, hasUnresolvedParams=hasUnresolvedParams@entry=false, plannerRestrictionContext=plannerRestrictionContext@entry=0x21ee998)
    at planner/distributed_planner.c:786
#8  0x00007f85c71f7e6b in CreateDistributedPlannedStmt (planId=3, localPlan=localPlan@entry=0x2209f98, originalQuery=originalQuery@entry=0x2032110, query=query@entry=0x2032228, 
    boundParams=boundParams@entry=0x0, plannerRestrictionContext=plannerRestrictionContext@entry=0x21ee998) at planner/distributed_planner.c:515
#9  0x00007f85c71f81be in distributed_planner (parse=0x2032228, cursorOptions=256, boundParams=0x0) at planner/distributed_planner.c:189
#10 0x00000000006e162e in planner (parse=parse@entry=0x2032228, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at planner.c:261
#11 0x00000000007963da in pg_plan_query (querytree=querytree@entry=0x2032228, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:832
#12 0x00000000007964df in pg_plan_queries (querytrees=<optimized out>, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:898
#13 0x00000000007967bb in exec_simple_query (query_string=query_string@entry=0x2030f68 "SELECT * FROM part, lineitem WHERE p_partkey = l_partkey;") at postgres.c:1073
#14 0x0000000000798571 in PostgresMain (argc=<optimized out>, argv=argv@entry=0x20a54f8, dbname=0x20a5390 "postgres", username=<optimized out>) at postgres.c:4182
#15 0x0000000000719dad in BackendRun (port=port@entry=0x2098da0) at postmaster.c:4358
#16 0x000000000071c9d2 in BackendStartup (port=port@entry=0x2098da0) at postmaster.c:4030
#17 0x000000000071cc7b in ServerLoop () at postmaster.c:1707
#18 0x000000000071df16 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x202bb80) at postmaster.c:1380
#19 0x000000000068580f in main (argc=3, argv=0x202bb80) at main.c:228

It is trying to do re-partitioning, but it's failing for a table with no shards.