Skip to content

Commit 2dd506b

Browse files
Revert "Teach DSM registry to ERROR if attaching to an uninitialized entry."
This reverts commit 1165a93 (and the corresponding commits on the back-branches). In a follow-up commit, we'll teach the registry to retry entry initialization instead of leaving it in a permanently failed state. Reviewed-by: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/E1vJHUk-006I7r-37%40gemulon.postgresql.org Backpatch-through: 17
1 parent e135e04 commit 2dd506b

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

src/backend/storage/ipc/dsm_registry.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ typedef struct DSMRegistryEntry
9393
{
9494
char name[NAMEDATALEN];
9595
DSMREntryType type;
96-
bool initialized;
9796
union
9897
{
9998
NamedDSMState dsm;
@@ -217,7 +216,6 @@ GetNamedDSMSegment(const char *name, size_t size,
217216
dsm_segment *seg;
218217

219218
entry->type = DSMR_ENTRY_TYPE_DSM;
220-
entry->initialized = false;
221219

222220
/* Initialize the segment. */
223221
seg = dsm_create(size, 0);
@@ -230,21 +228,13 @@ GetNamedDSMSegment(const char *name, size_t size,
230228

231229
if (init_callback)
232230
(*init_callback) (ret);
233-
234-
entry->initialized = true;
235231
}
236232
else if (entry->type != DSMR_ENTRY_TYPE_DSM)
237233
ereport(ERROR,
238-
(errmsg("requested DSM segment \"%s\" does not match type of existing entry",
239-
name)));
240-
else if (!entry->initialized)
241-
ereport(ERROR,
242-
(errmsg("requested DSM segment \"%s\" failed initialization",
243-
name)));
234+
(errmsg("requested DSM segment does not match type of existing entry")));
244235
else if (entry->dsm.size != size)
245236
ereport(ERROR,
246-
(errmsg("requested DSM segment \"%s\" does not match size of existing entry",
247-
name)));
237+
(errmsg("requested DSM segment size does not match size of existing segment")));
248238
else
249239
{
250240
NamedDSMState *state = &entry->dsm;
@@ -307,7 +297,6 @@ GetNamedDSA(const char *name, bool *found)
307297
NamedDSAState *state = &entry->dsa;
308298

309299
entry->type = DSMR_ENTRY_TYPE_DSA;
310-
entry->initialized = false;
311300

312301
/* Initialize the LWLock tranche for the DSA. */
313302
state->tranche = LWLockNewTrancheId(name);
@@ -319,17 +308,10 @@ GetNamedDSA(const char *name, bool *found)
319308

320309
/* Store handle for other backends to use. */
321310
state->handle = dsa_get_handle(ret);
322-
323-
entry->initialized = true;
324311
}
325312
else if (entry->type != DSMR_ENTRY_TYPE_DSA)
326313
ereport(ERROR,
327-
(errmsg("requested DSA \"%s\" does not match type of existing entry",
328-
name)));
329-
else if (!entry->initialized)
330-
ereport(ERROR,
331-
(errmsg("requested DSA \"%s\" failed initialization",
332-
name)));
314+
(errmsg("requested DSA does not match type of existing entry")));
333315
else
334316
{
335317
NamedDSAState *state = &entry->dsa;
@@ -390,7 +372,6 @@ GetNamedDSHash(const char *name, const dshash_parameters *params, bool *found)
390372
dsa_area *dsa;
391373

392374
entry->type = DSMR_ENTRY_TYPE_DSH;
393-
entry->initialized = false;
394375

395376
/* Initialize the LWLock tranche for the hash table. */
396377
dsh_state->tranche = LWLockNewTrancheId(name);
@@ -408,17 +389,10 @@ GetNamedDSHash(const char *name, const dshash_parameters *params, bool *found)
408389
/* Store handles for other backends to use. */
409390
dsh_state->dsa_handle = dsa_get_handle(dsa);
410391
dsh_state->dsh_handle = dshash_get_hash_table_handle(ret);
411-
412-
entry->initialized = true;
413392
}
414393
else if (entry->type != DSMR_ENTRY_TYPE_DSH)
415394
ereport(ERROR,
416-
(errmsg("requested DSHash \"%s\" does not match type of existing entry",
417-
name)));
418-
else if (!entry->initialized)
419-
ereport(ERROR,
420-
(errmsg("requested DSHash \"%s\" failed initialization",
421-
name)));
395+
(errmsg("requested DSHash does not match type of existing entry")));
422396
else
423397
{
424398
NamedDSHState *dsh_state = &entry->dsh;

0 commit comments

Comments
 (0)