Hi hackers,
(CC: Jacob, who was an author of 226e49cb)

I found a possible oversight in 226e49cb. pg_createsubscriber could fail due to
a missing configuration for output_plugin_libraries. Please see the reproducer
and a fix patch.

Background
========
226e49cb added a GUC parameter to specify trusted output plugins, and slot 
creation
would fail if a give plugin is not listed there.

```
postgres=# SHOW output_plugin_libraries ;
 output_plugin_libraries 
-------------------------
 test_decoding
(1 row)

postgres=# SELECT * FROM pg_create_logical_replication_slot('s1', 'pgoutput');
ERROR:  library "pgoutput" may not be used as an output plugin
HINT:  If it is safe for all REPLICATION users to use this library as an output 
plugin, add it to "output_plugin_libraries" and reload the server configuration.
```

Found issues
========
pg_createsubscriber command creates replication slots with plugin 'pgoutput',
without checking the GUC. This meant if the plugin name is not specified in the
parameter, --dry-run mode passes but actual convertion fails.
It's very surprising for users and should be avoided.

Attached 0001 patch is a reproducer, which is not intented to be pushed.

Possible fix
=======
I think pg_createsubscriber can check the parameter in check_publisher().
Attached 0002 patch does the same.

Note
====
BTW, I noticed that `char *max_slot_wal_keep_size` is pg_strdup'd but not 
free'd.
0003 fixes that.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment: v1-0001-Reproduce-missing-output_plugin_libraries-issue.patch
Description: v1-0001-Reproduce-missing-output_plugin_libraries-issue.patch

Attachment: v1-0002-pg_createsubscriber-ensure-output_plugin_librarie.patch
Description: v1-0002-pg_createsubscriber-ensure-output_plugin_librarie.patch

Attachment: v1-0003-free-allocated-memory-for-max_slot_wal_keep_size.patch
Description: v1-0003-free-allocated-memory-for-max_slot_wal_keep_size.patch

Reply via email to