@@ -285,8 +285,6 @@ static EnumItem *find_enumitem(TypeCacheEnumData *enumdata, Oid arg);
285
285
static int enum_oid_cmp (const void * left , const void * right );
286
286
static void shared_record_typmod_registry_detach (dsm_segment * segment ,
287
287
Datum datum );
288
- static void shared_record_typmod_registry_worker_detach (dsm_segment * segment ,
289
- Datum datum );
290
288
static TupleDesc find_or_make_matching_shared_tupledesc (TupleDesc tupdesc );
291
289
static dsa_pointer share_tupledesc (dsa_area * area , TupleDesc tupdesc ,
292
290
uint32 typmod );
@@ -1768,8 +1766,9 @@ SharedRecordTypmodRegistryAttach(SharedRecordTypmodRegistry *registry)
1768
1766
* a freshly started parallel worker. If we ever support worker
1769
1767
* recycling, a worker would need to zap its local cache in between
1770
1768
* servicing different queries, in order to be able to call this and
1771
- * synchronize typmods with a new leader; see
1772
- * shared_record_typmod_registry_detach().
1769
+ * synchronize typmods with a new leader; but that's problematic because
1770
+ * we can't be very sure that record-typmod-related state hasn't escaped
1771
+ * to anywhere else in the process.
1773
1772
*/
1774
1773
Assert (NextRecordTypmod == 0 );
1775
1774
@@ -1788,11 +1787,12 @@ SharedRecordTypmodRegistryAttach(SharedRecordTypmodRegistry *registry)
1788
1787
MemoryContextSwitchTo (old_context );
1789
1788
1790
1789
/*
1791
- * We install a different detach callback that performs a more complete
1792
- * reset of backend local state.
1790
+ * Set up detach hook to run at worker exit. Currently this is the same
1791
+ * as the leader's detach hook, but in future they might need to be
1792
+ * different.
1793
1793
*/
1794
1794
on_dsm_detach (CurrentSession -> segment ,
1795
- shared_record_typmod_registry_worker_detach ,
1795
+ shared_record_typmod_registry_detach ,
1796
1796
PointerGetDatum (registry ));
1797
1797
1798
1798
/*
@@ -2353,10 +2353,8 @@ find_or_make_matching_shared_tupledesc(TupleDesc tupdesc)
2353
2353
}
2354
2354
2355
2355
/*
2356
- * Detach hook to forget about the current shared record typmod
2357
- * infrastructure. This is registered directly in leader backends, and
2358
- * reached only in case of error or shutdown. It's also reached indirectly
2359
- * via the worker detach callback below.
2356
+ * On-DSM-detach hook to forget about the current shared record typmod
2357
+ * infrastructure. This is currently used by both leader and workers.
2360
2358
*/
2361
2359
static void
2362
2360
shared_record_typmod_registry_detach (dsm_segment * segment , Datum datum )
@@ -2374,57 +2372,3 @@ shared_record_typmod_registry_detach(dsm_segment *segment, Datum datum)
2374
2372
}
2375
2373
CurrentSession -> shared_typmod_registry = NULL ;
2376
2374
}
2377
-
2378
- /*
2379
- * Deatch hook allowing workers to disconnect from shared record typmod
2380
- * registry. The resulting state should allow a worker to attach to a
2381
- * different leader, if worker reuse pools are invented.
2382
- */
2383
- static void
2384
- shared_record_typmod_registry_worker_detach (dsm_segment * segment , Datum datum )
2385
- {
2386
- /*
2387
- * Forget everything we learned about record typmods as part of the
2388
- * session we are disconnecting from, and return to the initial state.
2389
- */
2390
- if (RecordCacheArray != NULL )
2391
- {
2392
- int32 i ;
2393
-
2394
- for (i = 0 ; i < RecordCacheArrayLen ; ++ i )
2395
- {
2396
- if (RecordCacheArray [i ] != NULL )
2397
- {
2398
- TupleDesc tupdesc = RecordCacheArray [i ];
2399
-
2400
- /*
2401
- * Pointers to tuple descriptors in shared memory are not
2402
- * reference counted, so we are not responsible for freeing
2403
- * them. They'll survive as long as the shared session
2404
- * exists, which should be as long as the owning leader
2405
- * backend exists. In theory we do need to free local
2406
- * reference counted tuple descriptors however, and we can't
2407
- * do that with DescTupleDescRefCount() because we aren't
2408
- * using a resource owner. In practice we don't expect to
2409
- * find any non-shared TupleDesc object in a worker.
2410
- */
2411
- if (tupdesc -> tdrefcount != -1 )
2412
- {
2413
- Assert (tupdesc -> tdrefcount > 0 );
2414
- if (-- tupdesc -> tdrefcount == 0 )
2415
- FreeTupleDesc (tupdesc );
2416
- }
2417
- }
2418
- }
2419
- pfree (RecordCacheArray );
2420
- RecordCacheArray = NULL ;
2421
- }
2422
- if (RecordCacheHash != NULL )
2423
- {
2424
- hash_destroy (RecordCacheHash );
2425
- RecordCacheHash = NULL ;
2426
- }
2427
- NextRecordTypmod = 0 ;
2428
- /* Call the code common to leader and worker detach. */
2429
- shared_record_typmod_registry_detach (segment , datum );
2430
- }
0 commit comments