Merge pull request #65919 from kitaisreal/postgresql-source-cancel-query-comments

PostgreSQL source cancel query comments
This commit is contained in:
Nikolai Kochetov 2024-07-09 11:07:33 +00:00 committed by GitHub
commit ad798196e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -193,7 +193,15 @@ PostgreSQLSource<T>::~PostgreSQLSource()
{
if (stream)
{
/** Internally libpqxx::stream_from runs PostgreSQL copy query `COPY query TO STDOUT`.
* During transaction abort we try to execute PostgreSQL `ROLLBACK` command and if
* copy query is not cancelled, we wait until it finishes.
*/
tx->conn().cancel_query();
/** If stream is not closed, libpqxx::stream_from closes stream in destructor, but that way
* exception is added into transaction pending error and we can potentially ignore exception message.
*/
stream->close();
}