Skip to content

When I execute a use case of pg_pathman on postgresql 12.7, a core file is generated. #230

Open
@LJXLJX1

Description

@LJXLJX1

Problem description

When I execute a use case of pg_pathman on postgresql 12.7, a core file is generated

core file:
[dytestpg@host-10-57-68-13 corefile]$ gdb /home/dytestpg/postgres/bin/postgres /corefile/core-1625843430-postgres-18236-6

Errors:
void
heap_insert(Relation relation, HeapTuple tup, CommandId cid,
int options, BulkInsertState bistate)
{
TransactionId xid = GetCurrentTransactionId();
HeapTuple heaptup;
Buffer buffer;
Buffer vmbuffer = InvalidBuffer;
bool all_visible_cleared = false;

/* Cheap, simplistic check that the tuple matches the rel's rowtype. */
Assert(HeapTupleHeaderGetNatts(tup->t_data) <=
	   RelationGetNumberOfAttributes(relation));

Breakpoint 1, heap_insert (relation=0x7f8a3a221998, tup=0x1471e70, cid=0, options=0, bistate=0x0) at heapam.c:1883
3: * relation->rd_rel = {oid = 73801, relname = {data = "test_12", '\000' <repeats 56 times>}, relnamespace = 73728, reltype = 73803, reloftype = 0, relowner = 10, relam = 2,
relfilenode = 73801, reltablespace = 0, relpages = 0, reltuples = 0, relallvisible = 0, reltoastrelid = 0, relhasindex = false, relisshared = false, relpersistence = 112 'p',
relkind = 114 'r', relnatts = 2, relchecks = 1, relhasrules = false, relhastriggers = false, relhassubclass = false, relrowsecurity = false, relforcerowsecurity = false,
relispopulated = true, relreplident = 100 'd', relispartition = false, relrewrite = 0, relfrozenxid = 1136, relminmxid = 1}
2: RelationGetNumberOfAttributes(relation) = 2
1: HeapTupleHeaderGetNatts(tup->t_data) = 3

The use cases that report errors are executed in sequence, and errors will be reported at the end.

/*


  • NOTE: This test behaves differenly on < 11 because planner now turns
  • Row(Const, Const) into just Const of record type, apparently since 3decd150

/
\set VERBOSITY terse
SET search_path = 'public';
CREATE EXTENSION pg_pathman;
CREATE SCHEMA test_updates;
/

  • Test UPDATEs on a partition with different TupleDescriptor.
    /
    /
    create partitioned table */
    CREATE TABLE test_updates.test(a FLOAT4, val INT4 NOT NULL, b FLOAT8);
    INSERT INTO test_updates.test SELECT i, i, i FROM generate_series(1, 100) AS i;
    SELECT create_range_partitions('test_updates.test', 'val', 1, 10);
    create_range_partitions

                  10

(1 row)

/* drop column 'a' /
ALTER TABLE test_updates.test DROP COLUMN a;
/
append new partition */
SELECT append_range_partition('test_updates.test');
append_range_partition

test_updates.test_11
(1 row)

INSERT INTO test_updates.test_11 (val, b) VALUES (101, 10);
VACUUM ANALYZE;
/* tuple descs are the same */
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0 WHERE val = 1;
QUERY PLAN

Update on test_1
-> Seq Scan on test_1
Filter: (val = 1)
(3 rows)

UPDATE test_updates.test SET b = 0 WHERE val = 1 RETURNING *, tableoid::REGCLASS;
val | b | tableoid
-----+---+---------------------
1 | 0 | test_updates.test_1
(1 row)

/* tuple descs are different */
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0 WHERE val = 101;
QUERY PLAN

Update on test_11
-> Seq Scan on test_11
Filter: (val = 101)
(3 rows)

UPDATE test_updates.test SET b = 0 WHERE val = 101 RETURNING *, tableoid::REGCLASS;
val | b | tableoid
-----+---+----------------------
101 | 0 | test_updates.test_11
(1 row)

CREATE TABLE test_updates.test_dummy (val INT4);
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET val = val + 1
WHERE val = 101 AND val = ANY (TABLE test_updates.test_dummy)
RETURNING *, tableoid::REGCLASS;
QUERY PLAN

Update on test_11
-> Nested Loop Semi Join
-> Seq Scan on test_11
Filter: (val = 101)
-> Seq Scan on test_dummy
Filter: (val = 101)
(6 rows)

EXPLAIN (COSTS OFF) UPDATE test_updates.test t1 SET b = 0
FROM test_updates.test_dummy t2
WHERE t1.val = 101 AND t1.val = t2.val
RETURNING t1.*, t1.tableoid::REGCLASS;
QUERY PLAN

Update on test_11 t1
-> Nested Loop
-> Seq Scan on test_11 t1
Filter: (val = 101)
-> Seq Scan on test_dummy t2
Filter: (val = 101)
(6 rows)

EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0
WHERE val = 101 AND test >= (100, 8)
RETURNING *, tableoid::REGCLASS;
QUERY PLAN

Update on test_11
-> Seq Scan on test_11
Filter: (((test_11.*)::test_updates.test >= '(100,8)'::record) AND (val = 101))
(3 rows)

/* execute this one */
UPDATE test_updates.test SET b = 0
WHERE val = 101 AND test >= (100, -1)
RETURNING test;
test

(101,0)
(1 row)

DROP TABLE test_updates.test_dummy;
/* cross-partition updates (& different tuple descs) */
TRUNCATE test_updates.test;
SET pg_pathman.enable_partitionrouter = ON;
SELECT , (select count() from pg_attribute where attrelid = partition) as columns
FROM pathman_partition_list
ORDER BY range_min::int, range_max::int;
parent | partition | parttype | expr | range_min | range_max | columns
-------------------+----------------------+----------+------+-----------+-----------+---------
test_updates.test | test_updates.test_1 | 2 | val | 1 | 11 | 9
test_updates.test | test_updates.test_2 | 2 | val | 11 | 21 | 9
test_updates.test | test_updates.test_3 | 2 | val | 21 | 31 | 9
test_updates.test | test_updates.test_4 | 2 | val | 31 | 41 | 9
test_updates.test | test_updates.test_5 | 2 | val | 41 | 51 | 9
test_updates.test | test_updates.test_6 | 2 | val | 51 | 61 | 9
test_updates.test | test_updates.test_7 | 2 | val | 61 | 71 | 9
test_updates.test | test_updates.test_8 | 2 | val | 71 | 81 | 9
test_updates.test | test_updates.test_9 | 2 | val | 81 | 91 | 9
test_updates.test | test_updates.test_10 | 2 | val | 91 | 101 | 9
test_updates.test | test_updates.test_11 | 2 | val | 101 | 111 | 8
(11 rows)

INSERT INTO test_updates.test VALUES (105, 105);
UPDATE test_updates.test SET val = 106 WHERE val = 105 RETURNING *, tableoid::REGCLASS;
val | b | tableoid
-----+-----+----------------------
106 | 105 | test_updates.test_11
(1 row)

UPDATE test_updates.test SET val = 115 WHERE val = 106 RETURNING *, tableoid::REGCLASS;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost

Environment

postgres=# SELECT * FROM pg_extension
postgres-# ;
oid | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
-------+------------+----------+--------------+----------------+------------+---------------+--------------
13579 | plpgsql | 10 | 11 | f | 1.0 | |
16384 | pg_pathman | 10 | 2200 | f | 1.5 | {16386,16397} | {"",""}
(2 rows)

postgres=# SELECT version();
version

PostgreSQL 12.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit
(1 row)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions