On Fri, Mar 15, 2024 at 9:23 AM Euler Taveira <eu...@eulerto.com> wrote: >
Did you consider adding options for publication/subscription/slot names as mentioned in my previous email? As discussed in a few emails above, it would be quite confusing for users to identify the logical replication objects once the standby is converted to subscriber. * +static void +cleanup_objects_atexit(void) { ... conn = connect_database(dbinfo[i].pubconninfo, false); + if (conn != NULL) + { + if (dbinfo[i].made_publication) + drop_publication(conn, &dbinfo[i]); + if (dbinfo[i].made_replslot) + drop_replication_slot(conn, &dbinfo[i], dbinfo[i].subname); + disconnect_database(conn, false); + } + else + { + /* + * If a connection could not be established, inform the user + * that some objects were left on primary and should be + * removed before trying again. + */ + if (dbinfo[i].made_publication) + { + pg_log_warning("There might be a publication \"%s\" in database \"%s\" on primary", + dbinfo[i].pubname, dbinfo[i].dbname); + pg_log_warning_hint("Consider dropping this publication before trying again."); + } It seems we care only for publications created on the primary. Isn't it possible that some of the publications have been replicated to standby by that time, for example, in case failure happens after creating a few publications? IIUC, we don't care for standby cleanup after failure because it can't be used for streaming replication anymore. So, the only choice the user has is to recreate the standby and start the pg_createsubscriber again. This sounds questionable to me as to whether users would like this behavior. Does anyone else have an opinion on this point? I see the below note in the patch: + If <application>pg_createsubscriber</application> fails while processing, + then the data directory is likely not in a state that can be recovered. It + is true if the target server was promoted. In such a case, creating a new + standby server is recommended. By reading this it is not completely clear whether the standby is not recoverable in case of any error or only an error after the target server is promoted. If others agree with this behavior then we should write the detailed reason for this somewhere in the comments as well unless it is already explained. -- With Regards, Amit Kapila.