Open frozenspider opened 2 years ago
Got this when working on #11944. Workaround is and has been to filter by a column other than oid.
yugabyte=# set yb_debug_report_error_stacktrace = on;
SET
yugabyte=# update pg_proc set proretset = true where oid = 8019;
WARNING: problem in alloc set MessageContext: bad single-chunk 0x382c420 in block 0x3828000
@ 0x7f61f754d2a9 YBCGetStackTrace (src/yb/common/ybc_util.cc:311)
@ 0x9c2ae2 elog_finish (src/postgres/src/backend/utils/error/elog.c:1473)
@ 0x9ecd67 AllocSetCheck (src/postgres/src/backend/utils/mmgr/aset.c:1448)
@ 0x9ed375 AllocSetReset (src/postgres/src/backend/utils/mmgr/aset.c:578)
@ 0x9f4326 MemoryContextResetOnly (src/postgres/src/backend/utils/mmgr/mcxt.c:230)
@ 0x9f471e MemoryContextReset (src/postgres/src/backend/utils/mmgr/mcxt.c:194)
@ 0x876549 PostgresMain (src/postgres/src/backend/tcop/postgres.c:5042)
@ 0x7df443 BackendRun (src/postgres/src/backend/postmaster/postmaster.c:4470)
@ 0x7df443 BackendStartup (src/postgres/src/backend/postmaster/postmaster.c:4136)
@ 0x7df443 ServerLoop (src/postgres/src/backend/postmaster/postmaster.c:1754)
@ 0x7e1649 PostmasterMain (src/postgres/src/backend/postmaster/postmaster.c:1417)
@ 0x736cd5 PostgresServerProcessMain (src/postgres/src/backend/main/main.c:234)
@ 0x736cf5
@ 0x7f61f68f1492
@ 0x484e2d
@ 0xffffffffffffffff
WARNING: problem in alloc set MessageContext: found inconsistent memory block 0x3828000
@ 0x7f61f754d2a9 YBCGetStackTrace (src/yb/common/ybc_util.cc:311)
@ 0x9c2ae2 elog_finish (src/postgres/src/backend/utils/error/elog.c:1473)
@ 0x9ecfe4 AllocSetCheck (src/postgres/src/backend/utils/mmgr/aset.c:1483)
@ 0x9ed375 AllocSetReset (src/postgres/src/backend/utils/mmgr/aset.c:578)
@ 0x9f4326 MemoryContextResetOnly (src/postgres/src/backend/utils/mmgr/mcxt.c:230)
@ 0x9f471e MemoryContextReset (src/postgres/src/backend/utils/mmgr/mcxt.c:194)
@ 0x876549 PostgresMain (src/postgres/src/backend/tcop/postgres.c:5042)
@ 0x7df443 BackendRun (src/postgres/src/backend/postmaster/postmaster.c:4470)
@ 0x7df443 BackendStartup (src/postgres/src/backend/postmaster/postmaster.c:4136)
@ 0x7df443 ServerLoop (src/postgres/src/backend/postmaster/postmaster.c:1754)
@ 0x7e1649 PostmasterMain (src/postgres/src/backend/postmaster/postmaster.c:1417)
@ 0x736cd5 PostgresServerProcessMain (src/postgres/src/backend/main/main.c:234)
@ 0x736cf5
@ 0x7f61f68f1492
@ 0x484e2d
@ 0xffffffffffffffff
Met this issue while I was working on #12816. I think the issue is related to pushdown UPDATE on catalog tables. See my experiment below. The current workaround is the same as Jason and Alex.
Stacktrace:
yugabyte=# SET yb_non_ddl_txn_for_sys_tables_allowed TO true;
yugabyte=# UPDATE pg_catalog.pg_class SET relfrozenxid = '3', relminmxid = '1' WHERE oid = 'hint_plan.hints'::pg_catalog.regclass;
WARNING: problem in alloc set MessageContext: bad single-chunk 0x11dc9d348 in block 0x11dc94000
@ 0x10d0e631c AllocSetCheck
@ 0x10d0f14cd MemoryContextCheck
@ 0x10d0f14ed MemoryContextCheck
@ 0x10ceb431a finish_xact_command
@ 0x10ceb783f exec_simple_query
@ 0x10ceb5d45 yb_exec_simple_query_impl
@ 0x10ceb5e7c yb_exec_query_wrapper_one_attempt
@ 0x10ceb5d1a yb_exec_query_wrapper
@ 0x10ceb1aa5 yb_exec_simple_query
@ 0x10ceb08cb PostgresMain
@ 0x10cde12d4 BackendRun
@ 0x10cde04c2 BackendStartup
@ 0x10cddf00c ServerLoop
@ 0x10cddc09a PostmasterMain
@ 0x10cce28b4 PostgresServerProcessMain
@ 0x10cce2ce2 main
WARNING: problem in alloc set MessageContext: found inconsistent memory block 0x11dc94000
@ 0x10d0e659e AllocSetCheck
@ 0x10d0f14cd MemoryContextCheck
@ 0x10d0f14ed MemoryContextCheck
@ 0x10ceb431a finish_xact_command
@ 0x10ceb783f exec_simple_query
@ 0x10ceb5d45 yb_exec_simple_query_impl
@ 0x10ceb5e7c yb_exec_query_wrapper_one_attempt
@ 0x10ceb5d1a yb_exec_query_wrapper
@ 0x10ceb1aa5 yb_exec_simple_query
@ 0x10ceb08cb PostgresMain
@ 0x10cde12d4 BackendRun
@ 0x10cde04c2 BackendStartup
@ 0x10cddf00c ServerLoop
@ 0x10cddc09a PostmasterMain
@ 0x10cce28b4 PostgresServerProcessMain
@ 0x10cce2ce2 main
WARNING: problem in alloc set MessageContext: bad single-chunk 0x11dc9d348 in block 0x11dc94000
@ 0x10d0e631c AllocSetCheck
@ 0x10d0e58cf AllocSetReset
@ 0x10d0f09c8 MemoryContextResetOnly
@ 0x10d0f0559 MemoryContextReset
@ 0x10ceb05fc PostgresMain
@ 0x10cde12d4 BackendRun
@ 0x10cde04c2 BackendStartup
@ 0x10cddf00c ServerLoop
@ 0x10cddc09a PostmasterMain
@ 0x10cce28b4 PostgresServerProcessMain
@ 0x10cce2ce2 main
WARNING: problem in alloc set MessageContext: found inconsistent memory block 0x11dc94000
@ 0x10d0e659e AllocSetCheck
@ 0x10d0e58cf AllocSetReset
@ 0x10d0f09c8 MemoryContextResetOnly
@ 0x10d0f0559 MemoryContextReset
@ 0x10ceb05fc PostgresMain
@ 0x10cde12d4 BackendRun
@ 0x10cde04c2 BackendStartup
@ 0x10cddf00c ServerLoop
@ 0x10cddc09a PostmasterMain
@ 0x10cce28b4 PostgresServerProcessMain
@ 0x10cce2ce2 main
UPDATE 0
Workaround:
yugabyte=# UPDATE pg_catalog.pg_class SET relfrozenxid = '3', relminmxid = '1' WHERE relname = 'hints';
UPDATE 1
yugabyte=# EXPLAIN UPDATE pg_catalog.pg_class SET relfrozenxid = '3', relminmxid = '1' WHERE relname = 'hints';
QUERY PLAN
------------------------------------------------------------------------------------------------------
Update on pg_class (cost=0.00..16.25 rows=100 width=522)
-> Index Scan using pg_class_relname_nsp_index on pg_class (cost=0.00..16.25 rows=100 width=522)
Index Cond: (relname = 'hints'::name)
(3 rows)
Experiment with changing the execution plan:
yugabyte=# EXPLAIN UPDATE pg_catalog.pg_class SET relfrozenxid = '3', relminmxid = '1' WHERE oid = 'hint_plan.hints'::pg_catalog.regclass;
WARNING: problem in alloc set PortalContext: bad single-chunk 0x115c2c648 in block 0x115c2c000
WARNING: problem in alloc set PortalContext: found inconsistent memory block 0x115c2c000
WARNING: problem in alloc set PortalContext: bad single-chunk 0x115c2c648 in block 0x115c2c000
WARNING: problem in alloc set PortalContext: found inconsistent memory block 0x115c2c000
QUERY PLAN
--------------------------------------------------------
Update on pg_class (cost=0.00..4.11 rows=1 width=522)
-> Result (cost=0.00..4.11 rows=1 width=522)
(2 rows)
yugabyte=# EXPLAIN /*+SeqScan(pg_class)*/ UPDATE pg_catalog.pg_class SET relfrozenxid = '3', relminmxid = '1' WHERE oid = 'hint_plan.hints'::pg_catalog.regclass;
QUERY PLAN
-----------------------------------------------------------------
Update on pg_class (cost=0.00..12.50 rows=1 width=522)
-> Seq Scan on pg_class (cost=0.00..12.50 rows=1 width=522)
Filter: (oid = '16388'::oid)
(3 rows)
Jira Link: DB-799
Description
This is especially relevant for YSQL upgrade where this is a valid use case for migrations.