Set GUC values in pgsql_create_logical_replication_slot()#960
Conversation
In the pgsql_create_logical_replication_slot() function, GUC values are not set for the connection, holding a snapshot. Therefore, if idle_in_transaction_session_timeout is set on the source, the session may be terminated due timeout and the snapshot may be lost.
|
Thanks for the fix — this is a real bug and the approach is on the right track. The problem with the current implementation
Suggested alternative The cleanest fix is to add a /* snapshot.c — after pgsql_init_stream */
if (!pgsql_server_version(&stream->pgsql)) { return false; }
GUC *settings =
stream->pgsql.pgversion_num < 90600 ? srcSettings95 : srcSettings;
if (!pgsql_create_logical_replication_slot(stream, slot, settings))
.../* pgsql.c — function signature */
bool pgsql_create_logical_replication_slot(LogicalStreamClient *client,
ReplicationSlot *slot,
GUC *settings)Inside One question worth confirming The GUCs are applied via |
Thank you for reviewing the patch. I've fixed it according to your recommendations.
I tested the fix as you suggested, and GUC idle_in_transaction_session_timeout is indeed set in the session, and the snapshot is not lost. Furthermore, we have repeatedly migrated a large production database from a server with a non-zero idle_in_transaction_session_timeout set, and the fix worked correctly. |
In the pgsql_create_logical_replication_slot() function, GUC values are not set for the connection, holding a snapshot.
Therefore, if idle_in_transaction_session_timeout is set on the source, the session may be terminated due timeout and the snapshot may be lost.