Re: Global temporary tables

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Global temporary tables
Date: 2026-07-07 09:06:01
Message-ID: CANWCAZah-o=gGsKA2+Zr5JZ82D_aWSR1t22mh0WK7eDeoSw5Ag@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 6, 2026 at 4:43 PM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> On Sun, 5 Jul 2026 at 10:58, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> > Yes, you're right. In that example, the pg_temp_class tuple gets lost
> > entirely. It really needs the same sort of sub XID tracking as the
> > usage/storage code
>
> Attached is v7, doing that.

Okay, I followed up with various attempts to get the new sub XID
tracking to do something dire, and couldn't find anything.

I did find something else, however:

set statement_timeout = '3s';
set debug_discard_caches = 1;

create global temporary table g (a int);

This enters an infinite loop after passing the point where the timeout
would have done any good, and it looks like
gtr_process_invalidated_gtrs() didn't take into account whole-cache
invalidation -- here's a partial backtrace:

(BTW, I forgot to mention I set this WoA in my last message -- I've
left it like that for now)

#21 0x00000000009c0d04 in RelationCacheInvalidate
(debug_discard=debug_discard(at)entry=true) at
../src/backend/utils/cache/relcache.c:3209
#22 0x00000000009b0c4e in InvalidateSystemCachesExtended
(debug_discard=debug_discard(at)entry=true) at
../src/backend/utils/cache/inval.c:793
#23 0x00000000009b0d5b in AcceptInvalidationMessages () at
../src/backend/utils/cache/inval.c:975
#24 0x0000000000858f80 in LockRelationOid (relid=2662, lockmode=1) at
../src/backend/storage/lmgr/lmgr.c:136
#25 0x00000000004c3dfd in relation_open
(relationId=relationId(at)entry=2662, lockmode=lockmode(at)entry=1) at
../src/backend/access/common/relation.c:56
#26 0x0000000000528579 in index_open
(relationId=relationId(at)entry=2662, lockmode=lockmode(at)entry=1) at
../src/backend/access/index/indexam.c:138
#27 0x0000000000527cf7 in systable_beginscan
(heapRelation=heapRelation(at)entry=0x7f2f5efbeeb8,
indexId=indexId(at)entry=2662, indexOK=indexOK(at)entry=true,
snapshot=snapshot(at)entry=0x0, nkeys=nkeys(at)entry=1,
key=key(at)entry=0x7ffc1b7043b0) at
../src/backend/access/index/genam.c:400
#28 0x00000000009b89fe in ScanPgRelation (targetRelId=1259,
indexOK=indexOK(at)entry=true,
force_non_historic=force_non_historic(at)entry=false)
at ../src/backend/utils/cache/relcache.c:397
#29 0x00000000009c060d in RelationReloadNailed
(relation=0x7f2f5efbeeb8) at
../src/backend/utils/cache/relcache.c:2540
#30 RelationRebuildRelation (relation=0x7f2f5efbeeb8) at
../src/backend/utils/cache/relcache.c:2738
#31 0x00000000009c0e76 in RelationIdGetRelation (relationId=<optimized
out>, relationId(at)entry=1259) at
../src/backend/utils/cache/relcache.c:2197
#32 0x00000000004c3e05 in relation_open (relationId=1259,
lockmode=lockmode(at)entry=1) at
../src/backend/access/common/relation.c:59
#33 0x0000000000561579 in table_open (relationId=<optimized out>,
lockmode=lockmode(at)entry=1) at ../src/backend/access/table/table.c:44
#34 0x00000000009add60 in SearchCatCacheMiss
(cache=cache(at)entry=0xaedd380, nkeys=nkeys(at)entry=1,
hashValue=628204292, hashIndex=4, v1=v1(at)entry=24576,
v2=v2(at)entry=0, v3=0, v4=0) at ../src/backend/utils/cache/catcache.c:1577
#35 0x00000000009ae039 in SearchCatCacheInternal (cache=0xaedd380,
nkeys=1, v1=24576, v2=0, v3=0, v4=0) at
../src/backend/utils/cache/catcache.c:1522
#36 0x00000000009c4159 in SearchSysCacheExists
(cacheId=cacheId(at)entry=RELOID, key1=key1(at)entry=24576,
key2=key2(at)entry=0, key3=key3(at)entry=0,
key4=key4(at)entry=0) at ../src/backend/utils/cache/syscache.c:434
#37 0x00000000005a9a43 in gtr_process_invalidated_gtrs () at
../src/backend/catalog/global_temp.c:706
#38 PreCommit_GlobalTempRelation () at ../src/backend/catalog/global_temp.c:1071
#39 0x0000000000577556 in CommitTransaction () at
../src/backend/access/transam/xact.c:2360

--
John Naylor
Amazon Web Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Cagri Biroglu 2026-07-07 09:41:55 Per-table resync for logical replication subscriptions
Previous Message shveta malik 2026-07-07 09:01:46 Re: Support EXCEPT for TABLES IN SCHEMA publications