RE: POC: enable logical decoding when wal_level = 'replica' without a server restart

Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>

From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Masahiko Sawada' <sawada.mshk@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, shveta malik <shveta.malik@gmail.com>
Date: 2025-07-28T12:34:21Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix regression test failure when wal_level is set to minimal.

  2. Toggle logical decoding dynamically based on logical slot presence.

  3. Disallow server start with sync_replication_slots = on and wal_level < logical.

Dear Sawada-san,

> Thank you for testing the patch!
> 
> I've reworked the locking part in the patch. The attached v4 patch
> should address all review comments including your previous
> comments[1].

Thanks for making the patch! I resumed to spending time for the project.
Here are my comments.

1.
Just in case - can you modify xlogdesc.c based on your fix?

2.
Currently pg_upgrade has below checking:
```
	if (nslots_on_old > 0 && strcmp(wal_level, "logical") != 0)
		pg_fatal("\"wal_level\" must be \"logical\" but is set to \"%s\"",
				 wal_level);
```

But this can be relaxed because wal_level can be adjusted appropriately. IIUC it
is enough to be higher than "minimal". Is it right?

3.
Currently pg_createsubscriber has below checking:
```
	if (strcmp(wal_level, "logical") != 0)
	{
		pg_log_error("publisher requires \"wal_level\" >= \"logical\"");
		failed = true;
	}
```

I feel the checking is completely not needed, because pg_createsubscriber needs
a streaming standby and wal_level = minimal cannot be set with this node placement.
Thought?

4.
We should update PG_CONTROL_VERSION and pg_controldata as well.

5.
I'm wondering how pg_resetwal handles. Since all the replication slot cannot be
used after the command, logicalDecodingEnabled can be set to false, right?

Best regards,
Hayato Kuroda
FUJITSU LIMITED